index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  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 || productType==3) ? '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>发货类型</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>快递公司</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>快递单号</view>
  55. <input type="text" placeholder="填写快递单号" 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. </view>
  63. <view class="item">
  64. <view class="trip" v-if="curExpress == 1">顺丰请输入单号 :收件人或寄件人手机号后四位</view>
  65. <view class="trip" v-if="curExpress == 1">例如:SF000000000000:3941</view>
  66. </view>
  67. </block>
  68. <block v-if="curExpress == 2">
  69. <view class="item acea-row row-between-wrapper">
  70. <view>快递公司</view>
  71. <view class="select-box">
  72. <picker class="pickerBox" @change="bindPickerChange" :value="seIndex" :range="logistics"
  73. range-key="name">
  74. <!-- <view></view> -->
  75. <view class="uni-input">{{logistics[seIndex].name}}</view>
  76. </picker>
  77. </view>
  78. </view>
  79. <view class="item acea-row row-between-wrapper" v-if="expTemp.length>0">
  80. <view>电子面单</view>
  81. <div class="picker-add">
  82. <picker class="pickerBox" @change="bindTempChange" :value="expIndex" :range="expTemp"
  83. range-key="title">
  84. <view class="uni-input">{{expTemp[expIndex].title}}</view>
  85. </picker>
  86. <div class="look" @click="previewImage">预览</div>
  87. </div>
  88. </view>
  89. <view class="item acea-row row-between-wrapper">
  90. <view>寄件人姓名:</view>
  91. <input type="text" placeholder="填写寄件人姓名" v-model="to_name" class="mode" />
  92. </view>
  93. <view class="item acea-row row-between-wrapper">
  94. <view>寄件人电话:</view>
  95. <input type="text" placeholder="填写寄件人电话" v-model="to_tel" class="mode" />
  96. </view>
  97. <view class="item acea-row row-between-wrapper">
  98. <view>寄件人地址:</view>
  99. <input type="text" placeholder="填写寄件人地址" v-model="to_addr" class="mode" />
  100. </view>
  101. </block>
  102. </view>
  103. </block>
  104. <view class="list" v-show="active === 1">
  105. <view class="item acea-row row-between-wrapper">
  106. <view>送货人</view>
  107. <view class="select-box" v-if="postPeople.length>0">
  108. <picker class="pickerBox" @change="bindPostChange" :value="postIndex" :range="postPeople"
  109. range-key="wx_name">
  110. <!-- <view></view> -->
  111. <view class="uni-input">{{postPeople[postIndex].wx_name}}</view>
  112. </picker>
  113. </view>
  114. </view>
  115. </view>
  116. <textarea v-show="active === 2" v-model="fictitious_content" class="textarea" @blur="bindTextAreaBlur"
  117. placeholder="备注" :maxlength="500" auto-height />
  118. <view class="item acea-row row-between-wrapper" v-if="totalNum>1&&active !== 2">
  119. <view>分单发货</view>
  120. <view class="mode acea-row row-middle row-right">
  121. <view class="goods" :class="curGoods === item.key ? 'on' : ''"
  122. v-for="(item, index) in orderGoods" :key="item.key" @click="changeGoods(item)">
  123. {{ item.title }}<span class="iconfont icon-xuanzhong2"></span>
  124. </view>
  125. </view>
  126. </view>
  127. <splitOrder :splitGoods="splitGoods" @getList="getList" v-if="curGoods"></splitOrder>
  128. </view>
  129. <view class="height-add"></view>
  130. <view class="confirm" @click="saveInfo">确认提交</view>
  131. </view>
  132. </template>
  133. <script>
  134. import {
  135. getAdminOrderDelivery,
  136. setAdminOrderDelivery,
  137. getLogistics,
  138. orderExportTemp,
  139. orderDeliveryInfo,
  140. orderOrderDelivery,
  141. orderSplitInfo,
  142. orderSplitDelivery
  143. } from "@/api/admin";
  144. import splitOrder from '@/components/splitOrder';
  145. export default {
  146. name: "GoodsDeliver",
  147. components: {
  148. splitOrder
  149. },
  150. props: {},
  151. data: function() {
  152. return {
  153. types: [{
  154. type: "express",
  155. title: "发货",
  156. key: 1
  157. },
  158. {
  159. type: "send",
  160. title: "送货",
  161. key: 2
  162. },
  163. {
  164. type: "fictitious",
  165. title: "无需物流",
  166. key: 3
  167. }
  168. ],
  169. expressType: [{
  170. title: '手动填写',
  171. key: 1
  172. },
  173. {
  174. title: '电子面单打印',
  175. key: 2
  176. },
  177. ],
  178. orderGoods: [
  179. {
  180. title:'开启',
  181. key: 1
  182. },
  183. {
  184. title:'关闭',
  185. key: 0
  186. }
  187. ],
  188. curExpress: 1,
  189. active: 0,
  190. order_id: "",
  191. delivery: [],
  192. logistics: [],
  193. delivery_type: "1",
  194. delivery_name: "",
  195. delivery_id: "",
  196. seIndex: 0,
  197. expIndex: 0,
  198. expTemp: [], // 快递模板
  199. to_name: '', // 发货人名称
  200. to_tel: '', // 发货人电话
  201. to_addr: "", // 发货人地址
  202. postPeople: [], //配送人
  203. postIndex: 0,
  204. fictitious_content: '',
  205. listId:0,
  206. curGoods:0,
  207. splitGoods:[],
  208. cartIds:[],
  209. totalNum:0,
  210. productType:0,
  211. // #ifdef H5
  212. isWeixin: this.$wechat.isWeixin()
  213. // #endif
  214. };
  215. },
  216. watch: {
  217. "$route.params.oid": function(newVal) {
  218. let that = this;
  219. if (newVal != undefined) {
  220. that.order_id = newVal;
  221. that.getIndex();
  222. }
  223. }
  224. },
  225. onLoad: function(option) {
  226. this.order_id = option.id;
  227. this.listId = option.listId;
  228. this.totalNum = option.totalNum;
  229. this.comeType = option.comeType;
  230. this.productType = option.productType
  231. if(this.productType==3){
  232. this.types.splice(0,2);
  233. this.delivery_type = 3;
  234. this.active = 2;
  235. }
  236. if(option.orderStatus == 8 || option.orderStatus == 4 || option.orderStatus == 9){
  237. this.curGoods = 1;
  238. this.orderGoods.pop();
  239. this.splitList();
  240. }
  241. this.getIndex();
  242. this.getLogistics();
  243. this.orderDeliveryInfo()
  244. this.geTorderOrderDelivery()
  245. },
  246. methods: {
  247. getList(val){
  248. let that = this;
  249. that.splitGoods = val;
  250. let cartIds = [];
  251. val.forEach((item)=>{
  252. if(item.checked){
  253. let i = {
  254. cart_id:item.cart_id,
  255. cart_num:item.surplus_num
  256. }
  257. cartIds.push(i)
  258. }
  259. })
  260. this.cartIds = cartIds;
  261. },
  262. splitList(){
  263. orderSplitInfo(this.listId).then(res=>{
  264. let list = res.data;
  265. list.forEach((item)=>{
  266. item.checked = false
  267. item.numShow = item.surplus_num
  268. })
  269. this.splitGoods = list;
  270. }).catch(err=>{
  271. return this.$util.Tips({
  272. title: err
  273. });
  274. })
  275. },
  276. // 点击获取拆单列表
  277. changeGoods(item){
  278. this.curGoods = item.key;
  279. if(item.key){
  280. this.splitList();
  281. }
  282. },
  283. // 扫描快递单号一维码
  284. scanCode() {
  285. // #ifdef MP
  286. let that = this;
  287. uni.scanCode({
  288. scanType: ['barCode'],
  289. success(res) {
  290. that.delivery_id = res.result;
  291. }
  292. })
  293. // #endif
  294. // #ifdef H5
  295. if (this.$wechat.isWeixin()) {
  296. this.$wechat.wechatEvevt('scanQRCode', {
  297. needResult: 1,
  298. scanType: ['barCode']
  299. }).then(res => {
  300. let result = res.resultStr.split(",");
  301. this.delivery_id = result[1];
  302. });
  303. }
  304. // #endif
  305. },
  306. // 预览图片
  307. previewImage() {
  308. uni.previewImage({
  309. urls: [this.expTemp[this.expIndex].pic],
  310. success: function() {
  311. },
  312. fail: function(error) {
  313. }
  314. });
  315. },
  316. // 获取配送员列表
  317. geTorderOrderDelivery() {
  318. orderOrderDelivery().then(res => {
  319. this.postPeople = res.data
  320. })
  321. },
  322. // 配送员选择
  323. bindPostChange(e) {
  324. this.postIndex = e.detail.value
  325. },
  326. // 选择发货类型
  327. changeExpTpe(item, index) {
  328. this.curExpress = item.key
  329. this.getLogistics(index || '');
  330. },
  331. changeType: function(item, index) {
  332. this.active = index;
  333. this.delivery_type = item.key;
  334. },
  335. getIndex: function() {
  336. let that = this;
  337. getAdminOrderDelivery(that.order_id).then(
  338. res => {
  339. that.delivery = res.data;
  340. },
  341. error => {
  342. that.$util.Tips({
  343. title: error
  344. })
  345. }
  346. );
  347. },
  348. getLogistics(status) {
  349. let that = this;
  350. getLogistics({
  351. status
  352. }).then(
  353. res => {
  354. that.logistics = res.data;
  355. that.getExpTemp(res.data[0].code)
  356. },
  357. error => {
  358. that.$util.Tips({
  359. title: error
  360. })
  361. }
  362. );
  363. },
  364. async saveInfo() {
  365. let that = this,
  366. delivery_type = that.delivery_type,
  367. delivery_name = that.logistics[that.seIndex].name,
  368. delivery_id = that.delivery_id,
  369. userName = that.delivery_name,
  370. save = {};
  371. save.delivery_type = delivery_type;
  372. save.delivery_code = that.logistics[that.seIndex].code
  373. save.delivery_name = that.logistics[that.seIndex].name
  374. save.type = that.active + 1
  375. if (delivery_type == 1 && this.curExpress == 1) {
  376. if (!delivery_id) {
  377. return this.$util.Tips({
  378. title: '请填写快递单号'
  379. })
  380. }
  381. save.express_record_type = that.curExpress
  382. save.delivery_id = delivery_id
  383. if(that.curGoods){
  384. that.setSplitInfo(save)
  385. }else{
  386. that.setInfo(save);
  387. }
  388. }
  389. if (delivery_type == 1 && this.curExpress == 2) {
  390. if (!that.to_name) {
  391. return this.$util.Tips({
  392. title: '请填写寄件人姓名'
  393. })
  394. }
  395. if (!that.to_tel) {
  396. return this.$util.Tips({
  397. title: '请填写寄件人手机号码'
  398. })
  399. }
  400. if (!(/^1[3456789]\d{9}$/.test(that.to_tel))) {
  401. return this.$util.Tips({
  402. title: '请填写寄件人手机号码'
  403. })
  404. }
  405. if (!that.to_addr) {
  406. return this.$util.Tips({
  407. title: '请填写寄件人地址'
  408. })
  409. }
  410. if (that.expTemp.length == 0) {
  411. return this.$util.Tips({
  412. title: '请选择电子面单'
  413. })
  414. }
  415. save.express_record_type = that.curExpress
  416. save.to_name = that.to_name
  417. save.to_tel = that.to_tel
  418. save.to_addr = that.to_addr
  419. save.express_temp_id = that.expTemp[that.expIndex].temp_id
  420. if(that.curGoods){
  421. that.setSplitInfo(save)
  422. }else{
  423. that.setInfo(save);
  424. }
  425. }
  426. if (delivery_type == 2) {
  427. if(!that.postPeople.length){
  428. return this.$util.Tips({
  429. title: '请在平台后台添加送货人'
  430. })
  431. }
  432. let obj = this.postPeople[this.postIndex]
  433. let params = {}
  434. params.type = that.delivery_type
  435. params.sh_delivery_name = obj.wx_name
  436. params.sh_delivery_id = obj.phone
  437. params.sh_delivery_uid = obj.uid
  438. if(that.curGoods){
  439. that.setSplitInfo(params)
  440. }else{
  441. that.setInfo(params);
  442. }
  443. }
  444. if (delivery_type == 3) {
  445. let params = {}
  446. params.type = that.delivery_type;
  447. params.fictitious_content = that.fictitious_content;
  448. if(that.curGoods){
  449. that.setSplitInfo(params)
  450. }else{
  451. that.setInfo(params);
  452. }
  453. }
  454. // switch (delivery_type) {
  455. // case "2":
  456. // if (!userName) {
  457. // return that.$util.Tips({
  458. // title: '请填写送货人姓名'
  459. // })
  460. // }
  461. // if (!delivery_id || !checkPhone(delivery_id)) {
  462. // return that.$util.Tips({
  463. // title: '请填写正确的手机号码'
  464. // })
  465. // }
  466. // save.delivery_name = userName;
  467. // save.delivery_id = delivery_id;
  468. // that.setInfo(save);
  469. // break;
  470. // case "1":
  471. // if (!delivery_id) {
  472. // return this.$util.Tips({
  473. // title: '请填写快递单号'
  474. // })
  475. // }
  476. // save.delivery_name = delivery_name;
  477. // save.delivery_id = delivery_id;
  478. // that.setInfo(save);
  479. // break;
  480. // case "3":
  481. // that.setInfo(save);
  482. // break;
  483. // }
  484. },
  485. setInfo: function(item) {
  486. let that = this;
  487. setAdminOrderDelivery(that.delivery.id, item).then(
  488. res => {
  489. that.$util.Tips({
  490. title: res.msg,
  491. icon: 'success',
  492. mask: true
  493. })
  494. setTimeout(res => {
  495. if(this.comeType == 2){
  496. uni.navigateTo({
  497. url:'/pages/admin/orderDetail/index?id='+this.order_id
  498. })
  499. }else{
  500. uni.navigateTo({
  501. url:'/pages/admin/orderList/index?types=1'
  502. })
  503. }
  504. }, 2000)
  505. },
  506. error => {
  507. that.$util.Tips({
  508. title: error
  509. })
  510. }
  511. );
  512. },
  513. setSplitInfo(item){
  514. if(!this.cartIds.length){
  515. return this.$util.Tips({
  516. title: '请选择发货商品'
  517. })
  518. }
  519. item.cart_ids = this.cartIds
  520. orderSplitDelivery(this.delivery.id, item).then(res=>{
  521. this.$util.Tips({
  522. title: res.msg,
  523. icon: 'success',
  524. mask: true
  525. })
  526. setTimeout(res => {
  527. if(this.comeType == 2){
  528. uni.navigateTo({
  529. url:'/pages/admin/orderDetail/index?id='+this.order_id
  530. })
  531. }else{
  532. uni.navigateTo({
  533. url:'/pages/admin/orderList/index?types=1'
  534. })
  535. }
  536. }, 2000)
  537. }).catch(err=>{
  538. this.$util.Tips({
  539. title: err
  540. })
  541. })
  542. },
  543. bindPickerChange(e) {
  544. this.seIndex = e.detail.value
  545. this.getExpTemp(this.logistics[e.detail.value].code)
  546. },
  547. bindTempChange(e) {
  548. this.expIndex = e.detail.value
  549. },
  550. getExpTemp(code) {
  551. orderExportTemp({
  552. com: code
  553. }).then(res => {
  554. this.expTemp = res.data.data
  555. })
  556. },
  557. // 获取订单打印默认配置
  558. orderDeliveryInfo() {
  559. orderDeliveryInfo().then(res => {
  560. this.to_name = res.data.to_name;
  561. this.to_tel = res.data.to_tel;
  562. this.to_addr = res.data.to_add;
  563. })
  564. }
  565. }
  566. };
  567. </script>
  568. <style lang="scss">
  569. .picker-add {
  570. display: flex;
  571. align-items: center;
  572. }
  573. .height-add {
  574. height:120upx;
  575. }
  576. /*发货*/
  577. .deliver-goods header {
  578. width: 100%;
  579. background-color: #fff;
  580. margin-top: 10upx;
  581. }
  582. .deliver-goods header .order-num {
  583. padding: 0 30upx;
  584. border-bottom: 1px solid #f5f5f5;
  585. height: 67upx;
  586. }
  587. .deliver-goods header .order-num .num {
  588. width: 430upx;
  589. font-size: 26upx;
  590. color: #282828;
  591. position: relative;
  592. }
  593. .deliver-goods header .order-num .num:after {
  594. position: absolute;
  595. content: '';
  596. width: 1px;
  597. height: 30upx;
  598. background-color: #ddd;
  599. top: 50%;
  600. margin-top: -15upx;
  601. right: 0;
  602. }
  603. .deliver-goods header .order-num .name {
  604. width: 260upx;
  605. font-size: 26upx;
  606. color: #282828;
  607. text-align: center;
  608. }
  609. .deliver-goods header .order-num .name .iconfont {
  610. font-size: 35upx;
  611. color: #477ef3;
  612. vertical-align: middle;
  613. margin-right: 10upx;
  614. }
  615. .deliver-goods header .address {
  616. font-size: 26upx;
  617. color: #868686;
  618. background-color: #fff;
  619. padding: 30upx;
  620. }
  621. .deliver-goods header .address .name {
  622. font-size: 34upx;
  623. color: #282828;
  624. margin-bottom: 10upx;
  625. }
  626. .deliver-goods header .address .name .phone {
  627. margin-left: 40upx;
  628. }
  629. .deliver-goods header .line {
  630. width: 100%;
  631. height: 3upx;
  632. }
  633. .deliver-goods header .line image {
  634. width: 100%;
  635. height: 100%;
  636. display: block;
  637. }
  638. .deliver-goods .wrapper {
  639. width: 100%;
  640. background-color: #fff;
  641. }
  642. .deliver-goods .wrapper .item {
  643. border-bottom: 1px solid #f0f0f0;
  644. padding: 0 30upx;
  645. height: 96upx;
  646. font-size: 32upx;
  647. color: #282828;
  648. position: relative;
  649. }
  650. .deliver-goods .wrapper .item .mode {
  651. width: 460upx;
  652. height: 100%;
  653. text-align: right;
  654. }
  655. .deliver-goods .wrapper .item .mode .iconfont {
  656. font-size: 30upx;
  657. margin-left: 13upx;
  658. }
  659. .deliver-goods .wrapper .item .mode .goods~.goods {
  660. margin-left: 30upx;
  661. }
  662. .deliver-goods .wrapper .item .mode .goods {
  663. color: #bbb;
  664. }
  665. .deliver-goods .wrapper .item .mode .goods.on {
  666. color: #477ef3;
  667. }
  668. .deliver-goods .wrapper .item .icon-up {
  669. position: absolute;
  670. font-size: 35upx;
  671. color: #2c2c2c;
  672. right: 30upx;
  673. }
  674. .deliver-goods .wrapper .item select {
  675. direction: rtl;
  676. padding-right: 60upx;
  677. position: relative;
  678. z-index: 2;
  679. }
  680. .deliver-goods .wrapper .item input::placeholder {
  681. color: #bbb;
  682. }
  683. .deliver-goods .confirm {
  684. font-size: 32upx;
  685. color: #fff;
  686. width: 100%;
  687. height: 100upx;
  688. background-color: #477ef3;
  689. text-align: center;
  690. line-height: 100upx;
  691. position: fixed;
  692. bottom: 0;
  693. }
  694. .select-box {
  695. flex: 1;
  696. height: 100%;
  697. .pickerBox {
  698. display: flex;
  699. align-items: center;
  700. justify-content: flex-end;
  701. width: 100%;
  702. height: 100%;
  703. }
  704. }
  705. .look {
  706. margin-left: 20rpx;
  707. color: #1890FF;
  708. }
  709. .textarea {
  710. display: block;
  711. min-height: 192rpx;
  712. padding: 30rpx;
  713. width: 100%;
  714. border-bottom: 1px solid #f0f0f0;
  715. }
  716. .icon-xiangji {
  717. font-size: 35rpx;
  718. color: #477ef3;
  719. }
  720. .trip {
  721. font-size: 22rpx;
  722. color: #ccc;
  723. padding: 6rpx 0;
  724. }
  725. </style>