index.vue 10 KB

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