index.vue 15 KB

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