index.vue 15 KB

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