index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  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 === index ? '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 === 0">
  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(`preview`)}}</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 === 1">
  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 === 2" v-model="fictitious_content" class="textarea" @blur="bindTextAreaBlur"
  115. :placeholder="$t(`remark`)" :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: "send",
  146. title: this.$t(`送货`),
  147. key: 2
  148. },
  149. {
  150. type: "fictitious",
  151. title: this.$t(`无需物流`),
  152. key: 3
  153. }
  154. ],
  155. expressType: [{
  156. title: this.$t(`手动填写`),
  157. key: 1
  158. },
  159. {
  160. title: this.$t(`电子面单打印`),
  161. key: 2
  162. },
  163. ],
  164. curExpress: 1,
  165. active: 0,
  166. order_id: "",
  167. delivery: [],
  168. logistics: [],
  169. delivery_type: "1",
  170. delivery_name: "",
  171. delivery_id: "",
  172. seIndex: 0,
  173. expIndex: 0,
  174. expTemp: [], // 快递模板
  175. to_name: '', // 发货人名称
  176. to_tel: '', // 发货人电话
  177. to_addr: "", // 发货人地址
  178. postPeople: [], //配送人
  179. postIndex: 0,
  180. fictitious_content: '',
  181. // #ifdef H5
  182. isWeixin: this.$wechat.isWeixin()
  183. // #endif
  184. };
  185. },
  186. watch: {
  187. "$route.params.oid": function(newVal) {
  188. let that = this;
  189. if (newVal != undefined) {
  190. that.order_id = newVal;
  191. that.getIndex();
  192. }
  193. }
  194. },
  195. onLoad: function(option) {
  196. this.order_id = option.id;
  197. this.getIndex();
  198. this.getLogistics();
  199. this.orderDeliveryInfo()
  200. this.geTorderOrderDelivery()
  201. },
  202. methods: {
  203. // 扫描快递单号一维码
  204. scanCode() {
  205. // #ifdef MP
  206. let that = this;
  207. uni.scanCode({
  208. scanType: ['barCode'],
  209. success(res) {
  210. that.delivery_id = res.result.replace('CODE_128,', '');
  211. }
  212. })
  213. // #endif
  214. // #ifdef H5
  215. if (this.$wechat.isWeixin()) {
  216. this.$wechat.wechatEvevt('scanQRCode', {
  217. needResult: 1,
  218. scanType: ['barCode']
  219. }).then(res => {
  220. this.delivery_id = res.resultStr.replace('CODE_128,', '');
  221. });
  222. }
  223. // #endif
  224. },
  225. // 预览图片
  226. previewImage() {
  227. uni.previewImage({
  228. urls: [this.expTemp[this.expIndex].pic],
  229. success: function() {
  230. },
  231. fail: function(error) {
  232. }
  233. });
  234. },
  235. // 获取配送员列表
  236. geTorderOrderDelivery() {
  237. orderOrderDelivery().then(res => {
  238. this.postPeople = res.data
  239. })
  240. },
  241. // 配送员选择
  242. bindPostChange(e) {
  243. this.postIndex = e.detail.value
  244. },
  245. // 选择发货类型
  246. changeExpTpe(item, index) {
  247. this.curExpress = item.key
  248. this.getLogistics(index || '');
  249. },
  250. changeType: function(item, index) {
  251. this.active = index;
  252. this.delivery_type = item.key;
  253. },
  254. getIndex: function() {
  255. let that = this;
  256. getAdminOrderDelivery(that.order_id).then(
  257. res => {
  258. that.delivery = res.data;
  259. },
  260. error => {
  261. that.$util.Tips({
  262. title: error
  263. })
  264. }
  265. );
  266. },
  267. getLogistics(status) {
  268. let that = this;
  269. getLogistics({
  270. status
  271. }).then(
  272. res => {
  273. that.logistics = res.data;
  274. that.getExpTemp(res.data[0].code)
  275. },
  276. error => {
  277. that.$util.Tips({
  278. title: error
  279. })
  280. }
  281. );
  282. },
  283. async saveInfo() {
  284. let that = this,
  285. delivery_type = that.delivery_type,
  286. delivery_name = that.logistics[that.seIndex].name,
  287. delivery_id = that.delivery_id,
  288. userName = that.delivery_name,
  289. save = {};
  290. save.delivery_type = delivery_name;
  291. save.delivery_code = that.logistics[that.seIndex].code
  292. save.delivery_name = that.logistics[that.seIndex].id
  293. save.type = that.active + 1
  294. if (delivery_type == 1 && this.curExpress == 1) {
  295. if (!delivery_id) {
  296. return this.$util.Tips({
  297. title: that.$t(`填写快递单号`)
  298. })
  299. }
  300. save.express_record_type = that.curExpress
  301. save.delivery_id = delivery_id
  302. that.setInfo(save);
  303. }
  304. if (delivery_type == 1 && this.curExpress == 2) {
  305. if (!that.to_name) {
  306. return this.$util.Tips({
  307. title: that.$t(`填写寄件人姓名`)
  308. })
  309. }
  310. if (!that.to_tel) {
  311. return this.$util.Tips({
  312. title: that.$t(`填写寄件人电话`)
  313. })
  314. }
  315. if (!(/^1[3456789]\d{9}$/.test(that.to_tel))) {
  316. return this.$util.Tips({
  317. title: that.$t(`填写寄件人电话`)
  318. })
  319. }
  320. if (!that.to_addr) {
  321. return this.$util.Tips({
  322. title: that.$t(`填写寄件人地址`)
  323. })
  324. }
  325. if (that.expTemp.length == 0) {
  326. return this.$util.Tips({
  327. title: that.$t(`请选择电子面单`)
  328. })
  329. }
  330. save.express_record_type = that.curExpress
  331. save.to_name = that.to_name
  332. save.to_tel = that.to_tel
  333. save.to_addr = that.to_addr
  334. save.express_temp_id = that.expTemp[that.expIndex].temp_id
  335. that.setInfo(save);
  336. }
  337. if (delivery_type == 2) {
  338. let obj = this.postPeople[this.postIndex]
  339. let params = {}
  340. params.type = that.delivery_type
  341. params.sh_delivery_name = obj.wx_name
  342. params.sh_delivery_id = obj.phone
  343. params.sh_delivery_uid = obj.uid
  344. that.setInfo(params);
  345. }
  346. if (delivery_type == 3) {
  347. let params = {}
  348. params.type = that.delivery_type;
  349. params.fictitious_content = that.fictitious_content;
  350. that.setInfo(params);
  351. }
  352. // switch (delivery_type) {
  353. // case "2":
  354. // if (!userName) {
  355. // return that.$util.Tips({
  356. // title: '请填写送货人姓名'
  357. // })
  358. // }
  359. // if (!delivery_id || !checkPhone(delivery_id)) {
  360. // return that.$util.Tips({
  361. // title: '请填写正确的手机号码'
  362. // })
  363. // }
  364. // save.delivery_name = userName;
  365. // save.delivery_id = delivery_id;
  366. // that.setInfo(save);
  367. // break;
  368. // case "1":
  369. // if (!delivery_id) {
  370. // return this.$util.Tips({
  371. // title: '请填写快递单号'
  372. // })
  373. // }
  374. // save.delivery_name = delivery_name;
  375. // save.delivery_id = delivery_id;
  376. // that.setInfo(save);
  377. // break;
  378. // case "3":
  379. // that.setInfo(save);
  380. // break;
  381. // }
  382. },
  383. setInfo: function(item) {
  384. let that = this;
  385. setAdminOrderDelivery(that.delivery.id, item).then(
  386. res => {
  387. that.$util.Tips({
  388. title: res.msg,
  389. icon: 'success',
  390. mask: true
  391. })
  392. setTimeout(res => {
  393. uni.navigateBack();
  394. }, 2000)
  395. },
  396. error => {
  397. that.$util.Tips({
  398. title: error
  399. })
  400. }
  401. );
  402. },
  403. bindPickerChange(e) {
  404. this.seIndex = e.detail.value
  405. this.getExpTemp(this.logistics[e.detail.value].code)
  406. },
  407. bindTempChange(e) {
  408. this.expIndex = e.detail.value
  409. },
  410. getExpTemp(code) {
  411. orderExportTemp({
  412. com: code
  413. }).then(res => {
  414. this.expTemp = res.data.data
  415. })
  416. },
  417. // 获取订单打印默认配置
  418. orderDeliveryInfo() {
  419. orderDeliveryInfo().then(res => {
  420. this.to_name = res.data.to_name;
  421. this.to_tel = res.data.to_tel;
  422. this.to_addr = res.data.to_add;
  423. })
  424. }
  425. }
  426. };
  427. </script>
  428. <style lang="scss">
  429. /*发货*/
  430. .deliver-goods header {
  431. width: 100%;
  432. background-color: #fff;
  433. margin-top: 10upx;
  434. }
  435. .deliver-goods header .order-num {
  436. padding: 0 30upx;
  437. border-bottom: 1px solid #f5f5f5;
  438. height: 67upx;
  439. }
  440. .deliver-goods header .order-num .num {
  441. width: 430upx;
  442. font-size: 26upx;
  443. color: #282828;
  444. position: relative;
  445. }
  446. .deliver-goods header .order-num .num:after {
  447. position: absolute;
  448. content: '';
  449. width: 1px;
  450. height: 30upx;
  451. background-color: #ddd;
  452. top: 50%;
  453. margin-top: -15upx;
  454. right: 0;
  455. }
  456. .deliver-goods header .order-num .name {
  457. width: 260upx;
  458. font-size: 26upx;
  459. color: #282828;
  460. text-align: center;
  461. }
  462. .deliver-goods header .order-num .name .iconfont {
  463. font-size: 35upx;
  464. color: #477ef3;
  465. vertical-align: middle;
  466. margin-right: 10upx;
  467. }
  468. .deliver-goods header .address {
  469. font-size: 26upx;
  470. color: #868686;
  471. background-color: #fff;
  472. padding: 30upx;
  473. }
  474. .deliver-goods header .address .name {
  475. font-size: 34upx;
  476. color: #282828;
  477. margin-bottom: 10upx;
  478. }
  479. .deliver-goods header .address .name .phone {
  480. margin-left: 40upx;
  481. }
  482. .deliver-goods header .line {
  483. width: 100%;
  484. height: 3upx;
  485. }
  486. .deliver-goods header .line image {
  487. width: 100%;
  488. height: 100%;
  489. display: block;
  490. }
  491. .deliver-goods .wrapper {
  492. width: 100%;
  493. background-color: #fff;
  494. }
  495. .deliver-goods .wrapper .item {
  496. border-bottom: 1px solid #f0f0f0;
  497. padding: 0 30upx;
  498. height: 96upx;
  499. font-size: 32upx;
  500. color: #282828;
  501. position: relative;
  502. }
  503. .deliver-goods .wrapper .item .mode {
  504. width: 460upx;
  505. height: 100%;
  506. text-align: right;
  507. }
  508. .deliver-goods .wrapper .item .mode .iconfont {
  509. font-size: 30upx;
  510. margin-left: 13upx;
  511. }
  512. .deliver-goods .wrapper .item .mode .goods~.goods {
  513. margin-left: 30upx;
  514. }
  515. .deliver-goods .wrapper .item .mode .goods {
  516. color: #bbb;
  517. }
  518. .deliver-goods .wrapper .item .mode .goods.on {
  519. color: #477ef3;
  520. }
  521. .deliver-goods .wrapper .item .icon-up {
  522. position: absolute;
  523. font-size: 35upx;
  524. color: #2c2c2c;
  525. right: 30upx;
  526. }
  527. .deliver-goods .wrapper .item select {
  528. direction: rtl;
  529. padding-right: 60upx;
  530. position: relative;
  531. z-index: 2;
  532. }
  533. .deliver-goods .wrapper .item input::placeholder {
  534. color: #bbb;
  535. }
  536. .deliver-goods .confirm {
  537. font-size: 32upx;
  538. color: #fff;
  539. width: 100%;
  540. height: 100upx;
  541. background-color: #477ef3;
  542. text-align: center;
  543. line-height: 100upx;
  544. position: fixed;
  545. bottom: 0;
  546. }
  547. .select-box {
  548. flex: 1;
  549. height: 100%;
  550. .pickerBox {
  551. display: flex;
  552. align-items: center;
  553. justify-content: flex-end;
  554. width: 100%;
  555. height: 100%;
  556. }
  557. }
  558. .look {
  559. margin-left: 20rpx;
  560. color: #1890FF;
  561. }
  562. .textarea {
  563. display: block;
  564. min-height: 192rpx;
  565. padding: 30rpx;
  566. }
  567. .icon-xiangji {
  568. font-size: 35rpx;
  569. color: #477ef3;
  570. }
  571. .trip {
  572. font-size: 22rpx;
  573. color: #ccc;
  574. padding: 6rpx 10rpx;
  575. }
  576. </style>