index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. <template>
  2. <view class="deliver-goods">
  3. <header>
  4. <view class="order-num acea-row row-between-wrapper">
  5. <view class="num line1">{{$t(`订单号`)}}:{{ order_id }}</view>
  6. <view class="name line1">
  7. <span class="iconfont icon-yonghu2"></span>{{ delivery.nickname }}
  8. </view>
  9. </view>
  10. <view class="address">
  11. <view class="name">
  12. {{ delivery.real_name
  13. }}<span class="phone">{{ delivery.user_phone }}</span>
  14. </view>
  15. <view>{{ delivery.user_address }}</view>
  16. </view>
  17. <view class="line">
  18. <image src="@/static/images/line.jpg" />
  19. </view>
  20. </header>
  21. <view class="wrapper">
  22. <view class="item acea-row row-between-wrapper">
  23. <view>{{$t(`发货方式`)}}</view>
  24. <view class="mode acea-row row-middle row-right">
  25. <view class="goods" :class="active === item.key ? 'on' : ''" v-for="(item, index) in types"
  26. :key="index" @click="changeType(item, index)">
  27. {{ item.title }}<span class="iconfont icon-xuanzhong2"></span>
  28. </view>
  29. </view>
  30. </view>
  31. <block v-if="logistics.length>0">
  32. <view class="list" v-show="active === 1">
  33. <view class="item acea-row row-between-wrapper" v-if="delivery.config_export_open == 1">
  34. <view>{{$t(`发货类型`)}}</view>
  35. <view class="mode acea-row row-middle row-right">
  36. <view class="goods" :class="curExpress === item.key ? 'on' : ''"
  37. v-for="(item, index) in expressType" :key="index" @click="changeExpTpe(item, index)">
  38. {{ item.title }}<span class="iconfont icon-xuanzhong2"></span>
  39. </view>
  40. </view>
  41. </view>
  42. <block v-if="curExpress == 1">
  43. <view class="item acea-row row-between-wrapper">
  44. <view>{{$t(`快递公司`)}}</view>
  45. <view class="select-box">
  46. <picker class="pickerBox" @change="bindPickerChange" :value="seIndex" :range="logistics"
  47. range-key="name">
  48. <!-- <view></view> -->
  49. <view class="uni-input">{{logistics[seIndex].name}}</view>
  50. </picker>
  51. </view>
  52. </view>
  53. <view class="item acea-row row-between-wrapper">
  54. <view>{{$t(`快递单号`)}}</view>
  55. <input type="text" :placeholder="$t(`填写快递单号`)" v-model="delivery_id" class="mode" />
  56. <!-- #ifdef MP -->
  57. <text class="iconfont icon-xiangji" @click="scanCode"></text>
  58. <!-- #endif -->
  59. <!-- #ifdef H5 -->
  60. <text v-if="isWeixin" class="iconfont icon-xiangji" @click="scanCode"></text>
  61. <!-- #endif -->
  62. <text class="trip" v-if="curExpress == 1">{{$t(`顺丰请输入单号 :收件人或寄件人手机号后四位`)}}</text>
  63. <text class="trip" v-if="curExpress == 1">{{$t(`例如:SF000000000000:3941`)}}</text>
  64. </view>
  65. </block>
  66. <block v-if="curExpress == 2">
  67. <view class="item acea-row row-between-wrapper">
  68. <view>{{$t(`快递公司`)}}</view>
  69. <view class="select-box">
  70. <picker class="pickerBox" @change="bindPickerChange" :value="seIndex" :range="logistics"
  71. range-key="name">
  72. <!-- <view></view> -->
  73. <view class="uni-input">{{logistics[seIndex].name}}</view>
  74. </picker>
  75. </view>
  76. </view>
  77. <view class="item acea-row row-between-wrapper" v-if="expTemp.length>0">
  78. <view>{{$t(`电子面单`)}}</view>
  79. <div style="display: flex;align-items: center;">
  80. <picker class="pickerBox" @change="bindTempChange" :value="expIndex" :range="expTemp"
  81. range-key="title">
  82. <view class="uni-input">{{expTemp[expIndex].title}}</view>
  83. </picker>
  84. <div class="look" @click="previewImage">{{$t(`预览`)}}</div>
  85. </div>
  86. </view>
  87. <view class="item acea-row row-between-wrapper">
  88. <view>{{$t(`寄件人姓名`)}}:</view>
  89. <input type="text" :placeholder="$t(`填写寄件人姓名`)" v-model="to_name" class="mode" />
  90. </view>
  91. <view class="item acea-row row-between-wrapper">
  92. <view>{{$t(`寄件人电话`)}}:</view>
  93. <input type="text" :placeholder="$t(`填写寄件人电话`)" v-model="to_tel" class="mode" />
  94. </view>
  95. <view class="item acea-row row-between-wrapper">
  96. <view>{{$t(`寄件人地址`)}}:</view>
  97. <input type="text" :placeholder="$t(`填写寄件人地址`)" v-model="to_addr" class="mode" />
  98. </view>
  99. </block>
  100. </view>
  101. </block>
  102. <view class="list" v-show="active === 2">
  103. <view class="item acea-row row-between-wrapper">
  104. <view>{{$t(`送货人`)}}</view>
  105. <view class="select-box" v-if="postPeople.length>0">
  106. <picker class="pickerBox" @change="bindPostChange" :value="postIndex" :range="postPeople"
  107. range-key="wx_name">
  108. <!-- <view></view> -->
  109. <view class="uni-input">{{postPeople[postIndex].wx_name}}</view>
  110. </picker>
  111. </view>
  112. </view>
  113. </view>
  114. <textarea v-show="active === 3" v-model="fictitious_content" class="textarea" @blur="bindTextAreaBlur"
  115. :placeholder="$t(`备注`)" :maxlength="500" auto-height />
  116. </view>
  117. <view style="height:1.2rem;"></view>
  118. <view class="confirm" @click="saveInfo">{{$t(`确认提交`)}}</view>
  119. </view>
  120. </template>
  121. <script>
  122. import {
  123. getAdminOrderDelivery,
  124. setAdminOrderDelivery,
  125. getLogistics,
  126. orderExportTemp,
  127. orderDeliveryInfo,
  128. orderOrderDelivery
  129. } from "@/api/admin";
  130. import {
  131. checkPhone
  132. } from '@/utils/validate.js'
  133. export default {
  134. name: "GoodsDeliver",
  135. components: {},
  136. props: {},
  137. data: function() {
  138. return {
  139. types: [{
  140. type: "express",
  141. title: this.$t(`发货`),
  142. key: 1
  143. },
  144. {
  145. type: "fictitious",
  146. title: this.$t(`无需物流`),
  147. key: 3
  148. }
  149. ],
  150. expressType: [{
  151. title: this.$t(`手动填写`),
  152. key: 1
  153. },
  154. {
  155. title: this.$t(`电子面单打印`),
  156. key: 2
  157. },
  158. ],
  159. curExpress: 1,
  160. active: 1,
  161. order_id: "",
  162. delivery: [],
  163. logistics: [],
  164. delivery_type: "1",
  165. delivery_name: "",
  166. delivery_id: "",
  167. seIndex: 0,
  168. expIndex: 0,
  169. expTemp: [], // 快递模板
  170. to_name: '', // 发货人名称
  171. to_tel: '', // 发货人电话
  172. to_addr: "", // 发货人地址
  173. postPeople: [], //配送人
  174. postIndex: 0,
  175. fictitious_content: '',
  176. // #ifdef H5
  177. isWeixin: this.$wechat.isWeixin()
  178. // #endif
  179. };
  180. },
  181. watch: {
  182. "$route.params.oid": function(newVal) {
  183. let that = this;
  184. if (newVal != undefined) {
  185. that.order_id = newVal;
  186. that.getIndex();
  187. }
  188. }
  189. },
  190. onLoad: function(option) {
  191. this.order_id = option.id;
  192. this.getIndex();
  193. this.getLogistics();
  194. this.orderDeliveryInfo()
  195. this.geTorderOrderDelivery()
  196. },
  197. methods: {
  198. // 扫描快递单号一维码
  199. scanCode() {
  200. // #ifdef MP
  201. let that = this;
  202. uni.scanCode({
  203. scanType: ['barCode'],
  204. success(res) {
  205. that.delivery_id = res.result.replace('CODE_128,', '');
  206. }
  207. })
  208. // #endif
  209. // #ifdef H5
  210. if (this.$wechat.isWeixin()) {
  211. this.$wechat.wechatEvevt('scanQRCode', {
  212. needResult: 1,
  213. scanType: ['barCode']
  214. }).then(res => {
  215. this.delivery_id = res.resultStr.replace('CODE_128,', '');
  216. });
  217. }
  218. // #endif
  219. },
  220. // 预览图片
  221. previewImage() {
  222. uni.previewImage({
  223. urls: [this.expTemp[this.expIndex].pic],
  224. success: function() {
  225. },
  226. fail: function(error) {
  227. }
  228. });
  229. },
  230. // 获取配送员列表
  231. geTorderOrderDelivery() {
  232. orderOrderDelivery().then(res => {
  233. if (res.data.length) {
  234. this.postPeople = res.data
  235. this.types.push({
  236. type: "send",
  237. title: this.$t(`送货`),
  238. key: 2
  239. })
  240. }
  241. })
  242. },
  243. // 配送员选择
  244. bindPostChange(e) {
  245. this.postIndex = e.detail.value
  246. },
  247. // 选择发货类型
  248. changeExpTpe(item, index) {
  249. this.curExpress = item.key
  250. this.getLogistics(index || '');
  251. },
  252. changeType: function(item, index) {
  253. this.active = item.key;
  254. this.delivery_type = item.key;
  255. },
  256. getIndex: function() {
  257. let that = this;
  258. getAdminOrderDelivery(that.order_id).then(
  259. res => {
  260. that.delivery = res.data;
  261. },
  262. error => {
  263. that.$util.Tips({
  264. title: error
  265. })
  266. }
  267. );
  268. },
  269. getLogistics(status) {
  270. let that = this;
  271. getLogistics({
  272. status
  273. }).then(
  274. res => {
  275. that.logistics = res.data;
  276. that.getExpTemp(res.data[0].code)
  277. },
  278. error => {
  279. that.$util.Tips({
  280. title: error
  281. })
  282. }
  283. );
  284. },
  285. async saveInfo() {
  286. let that = this,
  287. delivery_type = that.delivery_type,
  288. delivery_name = that.logistics[that.seIndex].name,
  289. delivery_id = that.delivery_id,
  290. userName = that.delivery_name,
  291. save = {};
  292. save.delivery_type = delivery_name;
  293. save.delivery_code = that.logistics[that.seIndex].code
  294. save.delivery_name = that.logistics[that.seIndex].id
  295. save.type = that.active + 1
  296. if (delivery_type == 1 && this.curExpress == 1) {
  297. if (!delivery_id) {
  298. return this.$util.Tips({
  299. title: that.$t(`填写快递单号`)
  300. })
  301. }
  302. save.express_record_type = that.curExpress
  303. save.delivery_id = delivery_id
  304. that.setInfo(save);
  305. }
  306. if (delivery_type == 1 && this.curExpress == 2) {
  307. if (!that.to_name) {
  308. return this.$util.Tips({
  309. title: that.$t(`填写寄件人姓名`)
  310. })
  311. }
  312. if (!that.to_tel) {
  313. return this.$util.Tips({
  314. title: that.$t(`填写寄件人电话`)
  315. })
  316. }
  317. if (!(/^1[3456789]\d{9}$/.test(that.to_tel))) {
  318. return this.$util.Tips({
  319. title: that.$t(`填写寄件人电话`)
  320. })
  321. }
  322. if (!that.to_addr) {
  323. return this.$util.Tips({
  324. title: that.$t(`填写寄件人地址`)
  325. })
  326. }
  327. if (that.expTemp.length == 0) {
  328. return this.$util.Tips({
  329. title: that.$t(`请选择电子面单`)
  330. })
  331. }
  332. save.express_record_type = that.curExpress
  333. save.to_name = that.to_name
  334. save.to_tel = that.to_tel
  335. save.to_addr = that.to_addr
  336. save.express_temp_id = that.expTemp[that.expIndex].temp_id
  337. that.setInfo(save);
  338. }
  339. if (delivery_type == 2) {
  340. let obj = this.postPeople[this.postIndex]
  341. let params = {}
  342. params.type = that.delivery_type
  343. params.sh_delivery_name = obj.wx_name
  344. params.sh_delivery_id = obj.phone
  345. params.sh_delivery_uid = obj.uid
  346. that.setInfo(params);
  347. }
  348. if (delivery_type == 3) {
  349. let params = {}
  350. params.type = that.delivery_type;
  351. params.fictitious_content = that.fictitious_content;
  352. that.setInfo(params);
  353. }
  354. // switch (delivery_type) {
  355. // case "2":
  356. // if (!userName) {
  357. // return that.$util.Tips({
  358. // title: '请填写送货人姓名'
  359. // })
  360. // }
  361. // if (!delivery_id || !checkPhone(delivery_id)) {
  362. // return that.$util.Tips({
  363. // title: '请填写正确的手机号码'
  364. // })
  365. // }
  366. // save.delivery_name = userName;
  367. // save.delivery_id = delivery_id;
  368. // that.setInfo(save);
  369. // break;
  370. // case "1":
  371. // if (!delivery_id) {
  372. // return this.$util.Tips({
  373. // title: '请填写快递单号'
  374. // })
  375. // }
  376. // save.delivery_name = delivery_name;
  377. // save.delivery_id = delivery_id;
  378. // that.setInfo(save);
  379. // break;
  380. // case "3":
  381. // that.setInfo(save);
  382. // break;
  383. // }
  384. },
  385. setInfo: function(item) {
  386. let that = this;
  387. setAdminOrderDelivery(that.delivery.id, item).then(
  388. res => {
  389. that.$util.Tips({
  390. title: res.msg,
  391. icon: 'success',
  392. mask: true
  393. })
  394. setTimeout(res => {
  395. uni.navigateBack();
  396. }, 2000)
  397. },
  398. error => {
  399. that.$util.Tips({
  400. title: error
  401. })
  402. }
  403. );
  404. },
  405. bindPickerChange(e) {
  406. this.seIndex = e.detail.value
  407. this.getExpTemp(this.logistics[e.detail.value].code)
  408. },
  409. bindTempChange(e) {
  410. this.expIndex = e.detail.value
  411. },
  412. getExpTemp(code) {
  413. orderExportTemp({
  414. com: code
  415. }).then(res => {
  416. this.expTemp = res.data.data
  417. })
  418. },
  419. // 获取订单打印默认配置
  420. orderDeliveryInfo() {
  421. orderDeliveryInfo().then(res => {
  422. this.to_name = res.data.to_name;
  423. this.to_tel = res.data.to_tel;
  424. this.to_addr = res.data.to_add;
  425. })
  426. }
  427. }
  428. };
  429. </script>
  430. <style lang="scss">
  431. /*发货*/
  432. .deliver-goods header {
  433. width: 100%;
  434. background-color: #fff;
  435. margin-top: 10upx;
  436. }
  437. .deliver-goods header .order-num {
  438. padding: 0 30upx;
  439. border-bottom: 1px solid #f5f5f5;
  440. height: 67upx;
  441. }
  442. .deliver-goods header .order-num .num {
  443. width: 430upx;
  444. font-size: 26upx;
  445. color: #282828;
  446. position: relative;
  447. }
  448. .deliver-goods header .order-num .num:after {
  449. position: absolute;
  450. content: '';
  451. width: 1px;
  452. height: 30upx;
  453. background-color: #ddd;
  454. top: 50%;
  455. margin-top: -15upx;
  456. right: 0;
  457. }
  458. .deliver-goods header .order-num .name {
  459. width: 260upx;
  460. font-size: 26upx;
  461. color: #282828;
  462. text-align: center;
  463. }
  464. .deliver-goods header .order-num .name .iconfont {
  465. font-size: 35upx;
  466. color: #477ef3;
  467. vertical-align: middle;
  468. margin-right: 10upx;
  469. }
  470. .deliver-goods header .address {
  471. font-size: 26upx;
  472. color: #868686;
  473. background-color: #fff;
  474. padding: 30upx;
  475. }
  476. .deliver-goods header .address .name {
  477. font-size: 34upx;
  478. color: #282828;
  479. margin-bottom: 10upx;
  480. }
  481. .deliver-goods header .address .name .phone {
  482. margin-left: 40upx;
  483. }
  484. .deliver-goods header .line {
  485. width: 100%;
  486. height: 3upx;
  487. }
  488. .deliver-goods header .line image {
  489. width: 100%;
  490. height: 100%;
  491. display: block;
  492. }
  493. .deliver-goods .wrapper {
  494. width: 100%;
  495. background-color: #fff;
  496. }
  497. .deliver-goods .wrapper .item {
  498. border-bottom: 1px solid #f0f0f0;
  499. padding: 0 30upx;
  500. height: 96upx;
  501. font-size: 32upx;
  502. color: #282828;
  503. position: relative;
  504. }
  505. .deliver-goods .wrapper .item .mode {
  506. width: 460upx;
  507. height: 100%;
  508. text-align: right;
  509. }
  510. .deliver-goods .wrapper .item .mode .iconfont {
  511. font-size: 30upx;
  512. margin-left: 13upx;
  513. }
  514. .deliver-goods .wrapper .item .mode .goods~.goods {
  515. margin-left: 30upx;
  516. }
  517. .deliver-goods .wrapper .item .mode .goods {
  518. color: #bbb;
  519. }
  520. .deliver-goods .wrapper .item .mode .goods.on {
  521. color: #477ef3;
  522. }
  523. .deliver-goods .wrapper .item .icon-up {
  524. position: absolute;
  525. font-size: 35upx;
  526. color: #2c2c2c;
  527. right: 30upx;
  528. }
  529. .deliver-goods .wrapper .item select {
  530. direction: rtl;
  531. padding-right: 60upx;
  532. position: relative;
  533. z-index: 2;
  534. }
  535. .deliver-goods .wrapper .item input::placeholder {
  536. color: #bbb;
  537. }
  538. .deliver-goods .confirm {
  539. font-size: 32upx;
  540. color: #fff;
  541. width: 100%;
  542. height: 100upx;
  543. background-color: #477ef3;
  544. text-align: center;
  545. line-height: 100upx;
  546. position: fixed;
  547. bottom: 0;
  548. }
  549. .select-box {
  550. flex: 1;
  551. height: 100%;
  552. .pickerBox {
  553. display: flex;
  554. align-items: center;
  555. justify-content: flex-end;
  556. width: 100%;
  557. height: 100%;
  558. }
  559. }
  560. .look {
  561. margin-left: 20rpx;
  562. color: #1890FF;
  563. }
  564. .textarea {
  565. display: block;
  566. min-height: 192rpx;
  567. padding: 30rpx;
  568. }
  569. .icon-xiangji {
  570. font-size: 35rpx;
  571. color: #477ef3;
  572. }
  573. .trip {
  574. font-size: 22rpx;
  575. color: #ccc;
  576. padding: 6rpx 10rpx;
  577. }
  578. </style>