addpaygoods.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <view class="container">
  3. <view class="information">
  4. <u-form :model="userInfo" ref="uForm" class="uForm">
  5. <u-form-item label="收货人姓名" prop="receiveName" label-width="160" required>
  6. <u-input v-model="userInfo.receiveName" :disabled="recipientsNumber?true:false" input-align="right" placeholder="请输入收货人姓名" />
  7. </u-form-item>
  8. <u-form-item label="收货人手机号" prop="receivePhone" label-width="180" required>
  9. <u-input v-model="userInfo.receivePhone" :disabled="recipientsNumber?true:false" input-align="right" placeholder="请输入收货人注册易粮易运的手机号" />
  10. </u-form-item>
  11. </u-form>
  12. </view>
  13. <button class="submit-btn" @click="submit" v-if="!recipientsNumber">提交</button>
  14. <button class="submit-btn btn-bgccolor" v-if="recipientsNumber">人数已达上限</button>
  15. <view class="c-row">
  16. <view class="">全部收货人({{dataList.receivingUsers.length}})</view>
  17. </view>
  18. <view class="c-row">
  19. <view class="title">我的用户昵称</view>
  20. <view class="phone">
  21. {{dataList.accountNumber}}
  22. </view>
  23. </view>
  24. <view class="information" v-for="(item,index) in dataList.receivingUsers">
  25. <view class="c-row">
  26. <view class="title">{{item.receiveName}}</view>
  27. <view class="con-list">
  28. <view class="phone">
  29. {{item.receivePhone}}
  30. </view>
  31. <image src="../../static/img/jiaoyi/shanchu.png" class="del" @click="del(item)"></image>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import uploadImage from '@/components/ossutil/uploadFile.js';
  39. import {
  40. mapState
  41. } from 'vuex';
  42. export default {
  43. name: "trust",
  44. data() {
  45. return {
  46. userInfo: {
  47. compId: "",
  48. infoId: "",
  49. receiveName: "",
  50. receivePhone: "",
  51. },
  52. dataList: {
  53. receivingUsers: []
  54. },
  55. rules: {
  56. receiveName: [{
  57. validator: (rule, value, callback) => {
  58. return this.$u.test.chinese(value)
  59. },
  60. message: '收货人姓名为汉字',
  61. trigger: ['change', 'blur']
  62. },
  63. {
  64. validator: (rule, value, callback) => {
  65. if (value.length > 10 || value.length < 2) return false
  66. return true
  67. },
  68. message: '请输入2-10个汉字',
  69. trigger: ['change', 'blur'],
  70. },
  71. ],
  72. receivePhone: [{
  73. validator: (rule, value, callback) => {
  74. return this.$u.test.mobile(value)
  75. },
  76. message: '手机号格式不正确',
  77. trigger: ['change', 'blur']
  78. },
  79. {
  80. validator: (rule, value, callback) => {
  81. return !this.checkMobile(value)
  82. },
  83. message: '手机号不能与其他收货人重复',
  84. trigger: ['blur']
  85. }
  86. ]
  87. },
  88. recipientsNumber:false
  89. }
  90. },
  91. computed: {
  92. },
  93. onShow() {},
  94. onReady() {
  95. this.$refs.uForm.setRules(this.rules);
  96. },
  97. onLoad(option) {
  98. debugger
  99. this.userInfo.infoId = option.id;
  100. this.getDetail(option.id);
  101. },
  102. methods: {
  103. // 手机号重复校验
  104. checkMobile(val) {
  105. debugger
  106. let _data = this.dataList.receivingUsers;
  107. if (_data == null || _data.length == 0) return false
  108. for (let i = 0; i < _data.length; i++) {
  109. if (val == _data[i].receivePhone) return true
  110. }
  111. return false
  112. },
  113. getDetail(id) {
  114. this.$api.doRequest('get', 'freightReceivingDispatching/getFreightReceivingDispatching', {
  115. "id": id
  116. }).then(res => {
  117. if (res.data.code == 200) {
  118. this.dataList = res.data.data
  119. if(this.dataList.length>=20) this.recipientsNumber = true
  120. console.log("this.dataList----------------------")
  121. console.log(this.dataList)
  122. } else {
  123. }
  124. }).catch(res => {
  125. // uni.showToast({
  126. // title: res.data.message,
  127. // icon: 'none',
  128. // duration: 2000
  129. // })
  130. })
  131. },
  132. submit() {
  133. debugger
  134. let that = this
  135. this.$refs.uForm.validate(valid => {
  136. if (valid) {
  137. that.$api.doRequest('post', '/freightReceivingDispatching/api/insertReceivingUser', this
  138. .userInfo).then(res => {
  139. debugger
  140. if (res.data.code == 200) {
  141. uni.showToast({
  142. title: '提交成功',
  143. icon: 'none',
  144. duration: 2000,
  145. success: function() {
  146. debugger
  147. }
  148. })
  149. } else {
  150. uni.showToast({
  151. title: '提交失败',
  152. icon: 'none',
  153. duration: 2000,
  154. success: function() {}
  155. })
  156. }
  157. }).catch(res => {
  158. // uni.showToast({
  159. // title: res.data.message,
  160. // icon: 'none',
  161. // duration: 2000
  162. // })
  163. })
  164. console.log('验证通过');
  165. } else {
  166. console.log('验证失败');
  167. return
  168. }
  169. });
  170. },
  171. del(val) {
  172. debugger
  173. let that = this
  174. uni.showModal({
  175. content: '确定删除该收货人?',
  176. cancelText: "取消",
  177. confirmText: "删除",
  178. success: function(res) {
  179. if (res.confirm) {
  180. that.$api.doRequest('post','/receivingUser/deleteInfo', {
  181. "id": val.id
  182. }).then(res => {
  183. if (res.data.code == 200) {
  184. uni.showToast({
  185. title: '删除成功',
  186. icon: 'none',
  187. duration: 2000,
  188. success: function() {debugger
  189. that.getDetail(that.userInfo.infoId)
  190. }
  191. })
  192. } else {
  193. uni.showToast({
  194. title: '删除失败',
  195. icon: 'none',
  196. duration: 2000,
  197. success: function() {}
  198. })
  199. }
  200. }).catch(res => {
  201. // uni.showToast({
  202. // title: res.data.message,
  203. // icon: 'none',
  204. // duration: 2000
  205. // })
  206. })
  207. } else if (res.cancel) {}
  208. }
  209. });
  210. }
  211. },
  212. }
  213. </script>
  214. <style scoped lang="scss">
  215. .container {
  216. padding: 10px 10px;
  217. background-color: #F5F6FA;
  218. }
  219. .cu-form-group textarea {
  220. text-align: right;
  221. }
  222. .commit {
  223. background: linear-gradient(45deg, #DF331C, #DA611A);
  224. color: #fff;
  225. }
  226. .c-row {
  227. display: -webkit-box;
  228. display: -webkit-flex;
  229. display: flex;
  230. -webkit-box-align: center;
  231. -webkit-align-items: center;
  232. align-items: center;
  233. padding: 20rpx 30rpx;
  234. position: relative;
  235. .title {
  236. width: 30%;
  237. // background: green;
  238. }
  239. }
  240. .con-list {
  241. display: flex;
  242. // background: red;
  243. width: 100%;
  244. justify-content: space-between;
  245. align-items: center;
  246. .del {
  247. display: block;
  248. width: 29rpx;
  249. height: 31rpx;
  250. }
  251. }
  252. .information {
  253. background-color: #FFFFFF;
  254. border-radius: 20px;
  255. margin-top: 10px;
  256. }
  257. .btn {
  258. margin-top: 10px;
  259. border-radius: 25px;
  260. background-color: #22C572;
  261. border: none;
  262. color: #FFFFFF;
  263. }
  264. .uForm {
  265. padding: 0 40rpx;
  266. }
  267. .custom-style {
  268. color: #606266;
  269. width: 400rpx;
  270. }
  271. .submit-btn {
  272. margin-top: 20rpx;
  273. width: 100%;
  274. background: #22C572;
  275. border-radius: 92rpx;
  276. font-size: 34rpx;
  277. font-weight: 500;
  278. color: #FFFFFF;
  279. }
  280. .btn-bgccolor{
  281. background: #D8DAE0;
  282. }
  283. </style>