deliveryman.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <template>
  2. <view class="clerk-page">
  3. <view class="clerk-list">
  4. <!-- <uni-swipe-action>
  5. <uni-swipe-action-item :right-options="options" :index="index" v-for="(item, index) in riderList"
  6. @click="swipeClick(index,item)" :key="item.riderId"> -->
  7. <view class="item" v-for="(item, index) in riderList" :key="item.riderId" style="width: 100%;">
  8. <view class="row">
  9. <view class="name">{{ item.riderName }}</view>
  10. <!-- <u-icon name="trash" size="26" color="#6c6c6c" @click="handItemRemove(item)"></u-icon> -->
  11. <view class="value flex-start">
  12. 状态:
  13. <switch :checked="item.status" @change="changeStatus(item)" size="22" class="switch" style="transform:scale(0.7)"></switch>
  14. </view>
  15. </view>
  16. <view class="row">
  17. <view class="phone">手机号: {{ item.telNo }}</view>
  18. <u-icon name="edit-pen" size="26" color="#6c6c6c" @click="handItemEdit(item)"></u-icon>
  19. </view>
  20. </view>
  21. <!-- </uni-swipe-action-item>
  22. </uni-swipe-action> -->
  23. </view>
  24. <view class="add-clerk" @click="addCleak">
  25. 添加专属配送员
  26. </view>
  27. <u-modal :show="deleteVisible" :title="modalTitle" closeOnClickOverlay showCancelButton confirmColor="#d64d3b"
  28. @confirm="handDelete" @cancel="deleteVisible = false" @close="deleteVisible = false">
  29. </u-modal>
  30. <u-modal :show="formVisible" :title="modalTitle" closeOnClickOverlay showCancelButton @confirm="handAdd"
  31. @cancel="formVisible = false" @close="formVisible = false">
  32. <view class="container">
  33. <view class="name">
  34. <u-input v-model="formItem.riderName" placeholder="请输入配送员姓名"></u-input>
  35. </view>
  36. <view class="phone">
  37. <u-input v-model="formItem.telNo" placeholder="请输入配送员手机号"></u-input>
  38. </view>
  39. <view class="password">
  40. 初始密码: 123456
  41. </view>
  42. </view>
  43. </u-modal>
  44. </view>
  45. </template>
  46. <script>
  47. import { mapState } from 'vuex';
  48. export default {
  49. data() {
  50. return {
  51. riderUrl: '/storeDeliveryManageApi/getStoreRiderList',
  52. updateUrl: '/storeDeliveryManageApi/updateRider',
  53. getOneUrl: '/storeDeliveryManageApi/getStoreRiderById',
  54. changeStatusUrl: '/storeDeliveryManageApi/changeStatus',
  55. modalTitle: '',
  56. deleteVisible: false,
  57. delItem: null,
  58. riderList: [],
  59. formItem: {
  60. riderId: '',
  61. riderName: '',
  62. telNo: ''
  63. },
  64. formVisible: '',
  65. options: [
  66. {
  67. text: '删除',
  68. style: {
  69. fontSize: '28rpx',
  70. backgroundColor: '#FF0000'
  71. }
  72. }
  73. ],
  74. }
  75. },
  76. computed: {
  77. ...mapState(['storeInfo'])
  78. },
  79. methods: {
  80. loadData () {
  81. var dateStr = (new Date()).getTime();
  82. var sign = this.getSign('' + this.storeInfo.storeUserId + dateStr);
  83. this.requst({
  84. url: this.riderUrl,
  85. data: {
  86. timestamp: dateStr,
  87. sign: sign,
  88. storeId: this.storeInfo.storeId,
  89. storeUserId: this.storeInfo.storeUserId
  90. },
  91. success: res => {
  92. if (res.data.rtnBean.rtnCode == 0) {
  93. this.riderList = res.data.list;
  94. }
  95. },
  96. fail: (e) => {
  97. console.log("接口调用失败:" + JSON.stringify(e));
  98. }
  99. })
  100. },
  101. changeStatus (item) {
  102. var dateStr = (new Date()).getTime();
  103. var sign = this.getSign('' + this.storeInfo.storeId + dateStr);
  104. let status = item.status == 1 ? 0 : 1
  105. this.requst({
  106. url: this.changeStatusUrl,
  107. data: {
  108. timestamp: dateStr,
  109. sign: sign,
  110. storeId: this.storeInfo.storeId,
  111. riderId: item.riderId,
  112. status: status
  113. },
  114. success: res => {
  115. if (res.data.rtnBean.rtnCode == 0) {
  116. this.loadData()
  117. }
  118. },
  119. fail: (e) => {
  120. console.log("接口调用失败:" + JSON.stringify(e));
  121. }
  122. })
  123. },
  124. close() {
  125. this.deleteVisible = false
  126. },
  127. handItemRemove(item) {
  128. this.modalTitle = `确定要删除配送员 [${item.riderName}] 吗?`
  129. this.delItem = item
  130. this.deleteVisible = true
  131. },
  132. handDelete() {
  133. console.log('这里写删除接口: ', this.delItem);
  134. this.delItem = null
  135. this.modalTitle = ''
  136. this.deleteVisible = false
  137. },
  138. handItemEdit(item) {
  139. this.getRider(item.riderId)
  140. },
  141. addCleak() {
  142. this.modalTitle = '添加配送员'
  143. this.formVisible = true
  144. },
  145. handAdd() {
  146. let reg = /^[1][3,4,5,7,8,9][0-9]{9}$/
  147. if (!this.formItem.riderName) {
  148. uni.showToast({
  149. title: '请输入配送员姓名',
  150. icon: 'none'
  151. })
  152. return
  153. }
  154. if (!this.formItem.telNo) {
  155. uni.showToast({
  156. title: '请输入配送员手机号码',
  157. icon: 'none'
  158. })
  159. return
  160. }
  161. if (!reg.test(this.formItem.telNo)) {
  162. uni.showToast({
  163. title: '请输入正确的手机号',
  164. icon: 'none'
  165. })
  166. return
  167. }
  168. var dateStr = (new Date()).getTime();
  169. var sign = this.getSign('' + this.storeInfo.storeUserId + dateStr);
  170. this.requst({
  171. url: this.updateUrl,
  172. data: {
  173. timestamp: dateStr,
  174. sign: sign,
  175. storeId: this.storeInfo.storeId,
  176. storeUserId: this.storeInfo.storeUserId,
  177. riderId: this.formItem.riderId,
  178. riderName: this.formItem.riderName,
  179. telNo: this.formItem.telNo
  180. },
  181. success: res => {
  182. if (res.data.rtnBean.rtnCode == 0) {
  183. this.formVisible = false
  184. this.formItem = {
  185. riderId: '',
  186. riderName: '',
  187. telNo: ''
  188. }
  189. this.loadData()
  190. this.modalVisible = false
  191. } else {
  192. if (res.data.rtnBean.rtnMsg != '') {
  193. this.$api.msg(res.data.rtnBean.rtnMsg);
  194. }
  195. }
  196. },
  197. fail: (e) => {
  198. console.log("接口调用失败:" + JSON.stringify(e));
  199. }
  200. })
  201. },
  202. getRider(id) {
  203. var dateStr = (new Date()).getTime();
  204. var sign = this.getSign('' + this.storeInfo.storeUserId + dateStr);
  205. this.requst({
  206. url: this.getOneUrl,
  207. data: {
  208. timestamp: dateStr,
  209. sign: sign,
  210. storeId: this.storeInfo.storeId,
  211. storeUserId: this.storeInfo.storeUserId,
  212. riderId: id
  213. },
  214. success: res => {
  215. if (res.data.rtnBean.rtnCode == 0) {
  216. this.formItem = res.data.obj;
  217. this.modalTitle = '编辑配送员'
  218. this.formVisible = true
  219. }
  220. },
  221. fail: (e) => {
  222. console.log("接口调用失败:" + JSON.stringify(e));
  223. }
  224. })
  225. },
  226. },
  227. onLoad() {
  228. this.loadData();
  229. }
  230. }
  231. </script>
  232. <style lang="scss" scoped>
  233. .clerk-page {
  234. width: 100vw;
  235. height: 100vh;
  236. background-color: #fff;
  237. }
  238. .clerk-list {
  239. height: calc(100vh - env(safe-area-inset-bottom) - 120rpx);
  240. height: calc(100vh - constant(safe-area-inset-bottom) - 120rpx);
  241. background-color: #f5f5f5;
  242. padding: 20rpx;
  243. box-sizing: border-box;
  244. .item {
  245. background-color: #fff;
  246. margin-bottom: 20rpx;
  247. border-radius: 10rpx;
  248. padding: 20rpx;
  249. display: flex;
  250. flex-direction: column;
  251. .row {
  252. @include between;
  253. margin-bottom: 20rpx;
  254. color: $text-color;
  255. }
  256. .name {
  257. font-size: 36rpx;
  258. }
  259. .phone {
  260. font-size: $font-lg;
  261. }
  262. .password {}
  263. }
  264. }
  265. .add-clerk {
  266. position: fixed;
  267. left: 10vw;
  268. width: 80vw;
  269. height: 80rpx;
  270. border-radius: 40rpx;
  271. @include flexCenter;
  272. color: #fff;
  273. background-color: $light-color;
  274. bottom: calc(20rpx + env(safe-area-inset-bottom));
  275. bottom: calc(20rpx + constant(safe-area-inset-bottom));
  276. }
  277. .container {
  278. .name {
  279. margin: 40rpx 0;
  280. }
  281. .phone {
  282. margin-bottom: 20rpx;
  283. }
  284. .password {
  285. text-align: center;
  286. font-size: $font-sm;
  287. color: $uni-color-button;
  288. }
  289. }
  290. </style>