index.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  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="searchValue" placeholder="请输入单号" suffixIcon="scan" @iconClick="scanInput" />
  5. <view class="item" v-for="(item, i) in waybillDelivery" :key="i" @click="itemClick(item)">
  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 permision from '@/common/permission.js';
  53. import { onLoad, onNavigationBarButtonTap } from '@dcloudio/uni-app';
  54. import { pickupWaybillDeliveryOrderURL, sendOutURL, deliveredURL, refuseURL, createTrackPodURL, cancelFedExPickUpURL } from '@/utils/api.js';
  55. const loading = ref(false);
  56. const loadingBtn = ref(false);
  57. const token = ref();
  58. const searchValue = ref();
  59. const waybillDelivery = ref([]);
  60. const messageType = ref();
  61. const messageText = ref();
  62. const messageRef = ref();
  63. const showRightRef = ref();
  64. const resetForm = () => {};
  65. const confirmForm = () => {
  66. showRightRef.value.close();
  67. };
  68. const copyOrderNo = (order_no) => {
  69. uni.setClipboardData({
  70. data: order_no,
  71. success: function () {
  72. uni.showToast({
  73. title: '复制成功',
  74. icon: 'success',
  75. duration: 2000
  76. });
  77. },
  78. fail: function () {
  79. console.log('复制失败');
  80. }
  81. });
  82. };
  83. const callPhone = (phoneNumber) => {
  84. console.log(phoneNumber);
  85. // #ifdef APP-PLUS
  86. uni.makePhoneCall({
  87. phoneNumber: phoneNumber,
  88. success: function () {
  89. console.log('拨打电话成功!');
  90. },
  91. fail: function () {
  92. console.log('拨打电话失败!');
  93. }
  94. });
  95. // #endif
  96. // #ifdef MP-WEIXIN
  97. wx.makePhoneCall({
  98. phoneNumber: phoneNumber,
  99. success: function () {
  100. console.log('拨打电话成功!');
  101. },
  102. fail: function () {
  103. console.log('拨打电话失败!');
  104. }
  105. });
  106. // #endif
  107. };
  108. const checkPermission = async () => {
  109. let status = permision.isIOS ? await permision.requestIOS('camera') : await permision.requestAndroid('android.permission.CAMERA');
  110. if (status === null || status === 1) {
  111. status = 1;
  112. } else {
  113. uni.showModal({
  114. content: 'Camera permission required',
  115. confirmText: 'Setting',
  116. success: function (res) {
  117. if (res.confirm) {
  118. permision.gotoAppSetting();
  119. }
  120. }
  121. });
  122. }
  123. return status;
  124. };
  125. const scanInput = async () => {
  126. // #ifdef APP-PLUS
  127. let status = await checkPermission();
  128. if (status !== 1) {
  129. return;
  130. }
  131. // #endif
  132. uni.scanCode({
  133. success: (res: any) => {
  134. // valiFormData.value.order_code = res.result;
  135. // onsubmit();
  136. },
  137. fail: (err) => {
  138. // 需要注意的是小程序扫码不需要申请相机权限
  139. }
  140. });
  141. };
  142. const itemClick = (item: any) => {
  143. uni.setStorageSync('selectItem', item);
  144. uni.navigateTo({
  145. url: '/pages/waybillDeliveryOrder/orderInfo?id=' + item.id
  146. });
  147. };
  148. const onButtonClick = async (row, value) => {
  149. if (value === 'send_out') {
  150. sendOut({ id: row.id });
  151. } else if (value === 'delivered') {
  152. //确认送达
  153. updateDelivered({ id: row.id });
  154. } else if (value === 'refuse') {
  155. updateRefuse({ id: row.id });
  156. } else if (value === 'create_track_pod') {
  157. createTrackPod({ id: row.id });
  158. } else if (value === 'edit') {
  159. // baTable.form.items = row;
  160. // baTable.form.operate = 'edit';
  161. } else if (value === 'generate_label') {
  162. // baTable.form.items = row;
  163. // generateLabelForm.id = row.id;
  164. // generateLabelVisible.value = true;
  165. } else if (value === 'fedex_appointment_pick_up') {
  166. // baTable.form.items = row;
  167. // baTable.form.operate = 'FedExPickUp';
  168. } else if (value === 'print_get_back_label') {
  169. // toPrintRetrieve(row);
  170. } else if (value === 'fedex_cancel_pick_up') {
  171. cancelFedExPickUp({ id: row.id });
  172. }
  173. };
  174. const sendOut = (data) => {
  175. loadingBtn.value = true;
  176. uni.request({
  177. url: sendOutURL,
  178. method: 'POST',
  179. header: {
  180. batoken: token.value
  181. },
  182. data: data,
  183. success: ({ data }: any) => {
  184. loadingBtn.value = false;
  185. messageType.value = 'success';
  186. messageText.value = '发出成功';
  187. messageRef.value.open();
  188. },
  189. fail: (err) => {
  190. loadingBtn.value = false;
  191. messageType.value = 'error';
  192. messageText.value = '发出失败,请稍后重试';
  193. messageRef.value.open();
  194. }
  195. });
  196. };
  197. const updateDelivered = (data) => {
  198. loadingBtn.value = true;
  199. uni.request({
  200. url: deliveredURL,
  201. method: 'POST',
  202. header: {
  203. batoken: token.value
  204. },
  205. data: data,
  206. success: ({ data }: any) => {
  207. loadingBtn.value = false;
  208. messageType.value = 'success';
  209. messageText.value = '确认送达成功';
  210. messageRef.value.open();
  211. },
  212. fail: (err) => {
  213. loadingBtn.value = false;
  214. messageType.value = 'error';
  215. messageText.value = '确认送达失败,请稍后重试';
  216. messageRef.value.open();
  217. }
  218. });
  219. };
  220. const updateRefuse = (data) => {
  221. loadingBtn.value = true;
  222. uni.request({
  223. url: refuseURL,
  224. method: 'POST',
  225. header: {
  226. batoken: token.value
  227. },
  228. data: data,
  229. success: ({ data }: any) => {
  230. loadingBtn.value = false;
  231. messageType.value = 'success';
  232. messageText.value = '已拒绝签收';
  233. messageRef.value.open();
  234. },
  235. fail: (err) => {
  236. loadingBtn.value = false;
  237. messageType.value = 'error';
  238. messageText.value = '修改失败,请稍后重试';
  239. messageRef.value.open();
  240. }
  241. });
  242. };
  243. const createTrackPod = (data) => {
  244. loadingBtn.value = true;
  245. uni.request({
  246. url: createTrackPodURL,
  247. method: 'POST',
  248. header: {
  249. batoken: token.value
  250. },
  251. data: data,
  252. success: ({ data }: any) => {
  253. loadingBtn.value = false;
  254. messageType.value = 'success';
  255. messageText.value = '同步成功';
  256. messageRef.value.open();
  257. },
  258. fail: (err) => {
  259. loadingBtn.value = false;
  260. messageType.value = 'error';
  261. messageText.value = '同步失败,请稍后重试';
  262. messageRef.value.open();
  263. }
  264. });
  265. };
  266. const cancelFedExPickUp = (data) => {
  267. loadingBtn.value = true;
  268. uni.request({
  269. url: cancelFedExPickUpURL,
  270. method: 'POST',
  271. header: {
  272. batoken: token.value
  273. },
  274. data: data,
  275. success: ({ data }: any) => {
  276. loadingBtn.value = false;
  277. messageType.value = 'success';
  278. messageText.value = '操作成功';
  279. messageRef.value.open();
  280. },
  281. fail: (err) => {
  282. loadingBtn.value = false;
  283. messageType.value = 'error';
  284. messageText.value = '操作失败,请稍后重试';
  285. messageRef.value.open();
  286. }
  287. });
  288. };
  289. const getList = () => {
  290. loading.value = true;
  291. uni.request({
  292. url: pickupWaybillDeliveryOrderURL + '/index',
  293. method: 'GET',
  294. header: {
  295. batoken: token.value
  296. },
  297. success: ({ data }: any) => {
  298. loading.value = false;
  299. console.log(data);
  300. if (data.code == 1) {
  301. waybillDelivery.value = data.data.list;
  302. } else {
  303. messageType.value = 'error';
  304. messageText.value = data.msg;
  305. messageRef.value.open();
  306. }
  307. },
  308. fail: (err) => {
  309. loading.value = false;
  310. }
  311. });
  312. };
  313. onLoad(() => {
  314. token.value = uni.getStorageSync('token');
  315. getList();
  316. });
  317. onNavigationBarButtonTap((event) => {
  318. if (event.index === 0) {
  319. showRightRef.value.open();
  320. }
  321. });
  322. </script>
  323. <style lang="scss" scoped>
  324. .list {
  325. margin: 0 auto;
  326. display: flex;
  327. flex-direction: column;
  328. // justify-content: center;
  329. align-items: center;
  330. flex: 1;
  331. .uni-easyinput {
  332. margin-top: 20rpx;
  333. width: calc(100% - 40rpx);
  334. }
  335. .item {
  336. margin-top: 20rpx;
  337. width: 95%;
  338. box-shadow: 0 5rpx 15rpx rgba(0, 0, 0, 0.2);
  339. border-radius: 20rpx;
  340. background-color: #fff;
  341. .order-no {
  342. padding: 14rpx;
  343. font-size: 16rpx;
  344. }
  345. .icon {
  346. margin-left: 5rpx;
  347. width: 24rpx;
  348. height: 24rpx;
  349. }
  350. .address-info {
  351. padding: 14rpx;
  352. font-size: 16rpx;
  353. margin-bottom: 10rpx;
  354. .info {
  355. display: flex;
  356. flex-direction: column;
  357. .user {
  358. margin-bottom: 10rpx;
  359. font-weight: bold;
  360. }
  361. .address {
  362. .city {
  363. font-size: 30rpx;
  364. font-weight: bold;
  365. }
  366. }
  367. }
  368. }
  369. }
  370. .is-empty {
  371. margin-top: 20rpx;
  372. }
  373. }
  374. .operations {
  375. display: flex;
  376. flex-direction: row;
  377. justify-content: flex-end;
  378. width: 100%;
  379. button {
  380. font-size: 16rpx;
  381. margin: 10rpx;
  382. }
  383. }
  384. .button-group {
  385. margin-top: 15px;
  386. display: flex;
  387. flex-direction: row;
  388. justify-content: space-around;
  389. button {
  390. display: flex;
  391. align-items: center;
  392. justify-content: center;
  393. height: 35px;
  394. width: 50%;
  395. margin-left: 10px;
  396. font-size: 16rpx;
  397. }
  398. .uni-icons {
  399. margin-right: 10px;
  400. }
  401. }
  402. </style>