index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <template>
  2. <view class="list">
  3. <uni-search-bar @confirm="search" :focus="true" v-model="searchValue" @blur="blur" @focus="focus" @input="input" @cancel="cancel" @clear="clear"></uni-search-bar>
  4. <!-- <uni-easyinput v-model="valiFormData.orderNum" placeholder="请输入单号" suffixIcon="scan" :focus="focusType" @iconClick="scan" /> -->
  5. <view class="item" v-for="(item, i) in waybillDelivery">
  6. <view class="order-no">
  7. <text>
  8. {{ item.order_no }}
  9. </text>
  10. <image @click="copyOrderNo(item.order_no)" class="icon" src="/static/copy.png" mode="aspectFill" />
  11. </view>
  12. <view class="address-info">
  13. <view class="info">
  14. <view class="user">
  15. <text>
  16. {{ item.address.first_name + ' ' + item.address.last_name }}
  17. {{ '+' + item.address.mobile_code + ' ' + item.address.mobile }}
  18. </text>
  19. <image @click="callPhone(item.address.mobile_code + ' ' + item.address.mobile)" class="icon" src="/static/call.png" mode="aspectFill" />
  20. </view>
  21. <view>
  22. <text class="address">
  23. <text class="city">{{ item.address.city }}</text>
  24. {{ item.address.zip_code }}
  25. </text>
  26. <image @click="copyOrderNo(item.address.zip_code)" class="icon" src="/static/copy.png" mode="aspectFill" />
  27. </view>
  28. </view>
  29. <view class="info"></view>
  30. </view>
  31. <view></view>
  32. <view class="operations">
  33. <button v-for="(operation, i) in item.operations" :key="i" @click="onButtonClick(item, operation.value)" type="info" size="mini">{{ operation.text }}</button>
  34. </view>
  35. </view>
  36. <view v-if="waybillDelivery.length === 0" class="is-empty">暂无派送单</view>
  37. <uni-popup ref="messageRef" type="message">
  38. <uni-popup-message :type="messageType" :message="messageText" :duration="2000"></uni-popup-message>
  39. </uni-popup>
  40. <uni-drawer ref="showRightRef" mode="right" :mask-click="true">
  41. <scroll-view style="height: 100%" scroll-y="true">
  42. <view class="button-group">
  43. <button @click="resetForm" type="info">重置</button>
  44. <button @click="confirmForm" type="primary">确认</button>
  45. </view>
  46. </scroll-view>
  47. </uni-drawer>
  48. </view>
  49. </template>
  50. <script setup lang="ts">
  51. import { reactive, ref } from 'vue';
  52. import { onLoad, onNavigationBarButtonTap } from '@dcloudio/uni-app';
  53. import { pickupWaybillDeliveryOrderURL, sendOutURL, deliveredURL, refuseURL, createTrackPodURL, cancelFedExPickUpURL } from '@/utils/api.js';
  54. const loading = ref(false);
  55. const loadingBtn = ref(false);
  56. const token = ref();
  57. const searchValue = ref();
  58. const waybillDelivery = ref([]);
  59. const messageType = ref();
  60. const messageText = ref();
  61. const messageRef = ref();
  62. const showRightRef = ref();
  63. const resetForm = () => {};
  64. const confirmForm = () => {
  65. showRightRef.value.close();
  66. };
  67. const copyOrderNo = (order_no) => {
  68. uni.setClipboardData({
  69. data: order_no,
  70. success: function () {
  71. uni.showToast({
  72. title: '复制成功',
  73. icon: 'success',
  74. duration: 2000
  75. });
  76. },
  77. fail: function () {
  78. console.log('复制失败');
  79. }
  80. });
  81. };
  82. const callPhone = (phoneNumber) => {
  83. console.log(phoneNumber);
  84. // #ifdef APP-PLUS
  85. uni.makePhoneCall({
  86. phoneNumber: phoneNumber,
  87. success: function () {
  88. console.log('拨打电话成功!');
  89. },
  90. fail: function () {
  91. console.log('拨打电话失败!');
  92. }
  93. });
  94. // #endif
  95. // #ifdef MP-WEIXIN
  96. wx.makePhoneCall({
  97. phoneNumber: phoneNumber,
  98. success: function () {
  99. console.log('拨打电话成功!');
  100. },
  101. fail: function () {
  102. console.log('拨打电话失败!');
  103. }
  104. });
  105. // #endif
  106. };
  107. const search = (res) => {
  108. uni.showToast({
  109. title: '搜索:' + res.value,
  110. icon: 'none'
  111. });
  112. };
  113. const input = (res) => {
  114. console.log('----input:', res);
  115. };
  116. const clear = (res) => {
  117. uni.showToast({
  118. title: 'clear事件,清除值为:' + res.value,
  119. icon: 'none'
  120. });
  121. };
  122. const blur = (res) => {
  123. uni.showToast({
  124. title: 'blur事件,输入值为:' + res.value,
  125. icon: 'none'
  126. });
  127. };
  128. const focus = (e) => {
  129. uni.showToast({
  130. title: 'focus事件,输出值为:' + e.value,
  131. icon: 'none'
  132. });
  133. };
  134. const cancel = (res) => {
  135. uni.showToast({
  136. title: '点击取消,输入值为:' + res.value,
  137. icon: 'none'
  138. });
  139. };
  140. const onButtonClick = async (row, value) => {
  141. if (value === 'send_out') {
  142. sendOut({ id: row.id });
  143. } else if (value === 'delivered') {
  144. //确认送达
  145. updateDelivered({ id: row.id });
  146. } else if (value === 'refuse') {
  147. updateRefuse({ id: row.id });
  148. } else if (value === 'create_track_pod') {
  149. createTrackPod({ id: row.id });
  150. } else if (value === 'edit') {
  151. // baTable.form.items = row;
  152. // baTable.form.operate = 'edit';
  153. } else if (value === 'generate_label') {
  154. // baTable.form.items = row;
  155. // generateLabelForm.id = row.id;
  156. // generateLabelVisible.value = true;
  157. } else if (value === 'fedex_appointment_pick_up') {
  158. // baTable.form.items = row;
  159. // baTable.form.operate = 'FedExPickUp';
  160. } else if (value === 'print_get_back_label') {
  161. // toPrintRetrieve(row);
  162. } else if (value === 'fedex_cancel_pick_up') {
  163. cancelFedExPickUp({ id: row.id });
  164. }
  165. };
  166. const sendOut = (data) => {
  167. loadingBtn.value = true;
  168. uni.request({
  169. url: sendOutURL,
  170. method: 'POST',
  171. header: {
  172. batoken: token.value
  173. },
  174. data: data,
  175. success: ({ data }: any) => {
  176. loadingBtn.value = false;
  177. messageType.value = 'success';
  178. messageText.value = '发出成功';
  179. messageRef.value.open();
  180. },
  181. fail: (err) => {
  182. loadingBtn.value = false;
  183. messageType.value = 'error';
  184. messageText.value = '发出失败,请稍后重试';
  185. messageRef.value.open();
  186. }
  187. });
  188. };
  189. const updateDelivered = (data) => {
  190. loadingBtn.value = true;
  191. uni.request({
  192. url: deliveredURL,
  193. method: 'POST',
  194. header: {
  195. batoken: token.value
  196. },
  197. data: data,
  198. success: ({ data }: any) => {
  199. loadingBtn.value = false;
  200. messageType.value = 'success';
  201. messageText.value = '确认送达成功';
  202. messageRef.value.open();
  203. },
  204. fail: (err) => {
  205. loadingBtn.value = false;
  206. messageType.value = 'error';
  207. messageText.value = '确认送达失败,请稍后重试';
  208. messageRef.value.open();
  209. }
  210. });
  211. };
  212. const updateRefuse = (data) => {
  213. loadingBtn.value = true;
  214. uni.request({
  215. url: refuseURL,
  216. method: 'POST',
  217. header: {
  218. batoken: token.value
  219. },
  220. data: data,
  221. success: ({ data }: any) => {
  222. loadingBtn.value = false;
  223. messageType.value = 'success';
  224. messageText.value = '已拒绝签收';
  225. messageRef.value.open();
  226. },
  227. fail: (err) => {
  228. loadingBtn.value = false;
  229. messageType.value = 'error';
  230. messageText.value = '修改失败,请稍后重试';
  231. messageRef.value.open();
  232. }
  233. });
  234. };
  235. const createTrackPod = (data) => {
  236. loadingBtn.value = true;
  237. uni.request({
  238. url: createTrackPodURL,
  239. method: 'POST',
  240. header: {
  241. batoken: token.value
  242. },
  243. data: data,
  244. success: ({ data }: any) => {
  245. loadingBtn.value = false;
  246. messageType.value = 'success';
  247. messageText.value = '同步成功';
  248. messageRef.value.open();
  249. },
  250. fail: (err) => {
  251. loadingBtn.value = false;
  252. messageType.value = 'error';
  253. messageText.value = '同步失败,请稍后重试';
  254. messageRef.value.open();
  255. }
  256. });
  257. };
  258. const cancelFedExPickUp = (data) => {
  259. loadingBtn.value = true;
  260. uni.request({
  261. url: cancelFedExPickUpURL,
  262. method: 'POST',
  263. header: {
  264. batoken: token.value
  265. },
  266. data: data,
  267. success: ({ data }: any) => {
  268. loadingBtn.value = false;
  269. messageType.value = 'success';
  270. messageText.value = '操作成功';
  271. messageRef.value.open();
  272. },
  273. fail: (err) => {
  274. loadingBtn.value = false;
  275. messageType.value = 'error';
  276. messageText.value = '操作失败,请稍后重试';
  277. messageRef.value.open();
  278. }
  279. });
  280. };
  281. const getList = () => {
  282. loading.value = true;
  283. uni.request({
  284. url: pickupWaybillDeliveryOrderURL + '/index',
  285. method: 'GET',
  286. header: {
  287. batoken: token.value
  288. },
  289. success: ({ data }: any) => {
  290. loading.value = false;
  291. console.log(data);
  292. if (data.code == 1) {
  293. waybillDelivery.value = data.data.list;
  294. } else {
  295. messageType.value = 'error';
  296. messageText.value = data.msg;
  297. messageRef.value.open();
  298. }
  299. },
  300. fail: (err) => {
  301. loading.value = false;
  302. }
  303. });
  304. };
  305. onLoad(() => {
  306. token.value = uni.getStorageSync('token');
  307. getList();
  308. });
  309. onNavigationBarButtonTap((event) => {
  310. if (event.index === 0) {
  311. showRightRef.value.open();
  312. }
  313. });
  314. </script>
  315. <style lang="scss" scoped>
  316. .list {
  317. margin: 0 auto;
  318. display: flex;
  319. flex-direction: column;
  320. // justify-content: center;
  321. align-items: center;
  322. flex: 1;
  323. .uni-searchbar {
  324. width: calc(100% - 40rpx);
  325. }
  326. .item {
  327. margin-top: 20rpx;
  328. width: 95%;
  329. box-shadow: 0 5rpx 15rpx rgba(0, 0, 0, 0.2);
  330. border-radius: 20rpx;
  331. background-color: #fff;
  332. .order-no {
  333. padding: 14rpx;
  334. font-size: 16rpx;
  335. }
  336. .icon {
  337. margin-left: 5rpx;
  338. width: 24rpx;
  339. height: 24rpx;
  340. }
  341. .address-info {
  342. padding: 14rpx;
  343. font-size: 16rpx;
  344. margin-bottom: 10rpx;
  345. .info {
  346. display: flex;
  347. flex-direction: column;
  348. .user {
  349. margin-bottom: 10rpx;
  350. font-weight: bold;
  351. }
  352. .address {
  353. .city {
  354. font-size: 30rpx;
  355. font-weight: bold;
  356. }
  357. }
  358. }
  359. }
  360. }
  361. }
  362. .operations {
  363. display: flex;
  364. flex-direction: row;
  365. justify-content: flex-end;
  366. width: 100%;
  367. button {
  368. font-size: 16rpx;
  369. margin: 10rpx;
  370. }
  371. }
  372. .button-group {
  373. margin-top: 15px;
  374. display: flex;
  375. flex-direction: row;
  376. justify-content: space-around;
  377. button {
  378. display: flex;
  379. align-items: center;
  380. justify-content: center;
  381. height: 35px;
  382. width: 50%;
  383. margin-left: 10px;
  384. font-size: 16rpx;
  385. }
  386. .uni-icons {
  387. margin-right: 10px;
  388. }
  389. }
  390. </style>