send.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. <template>
  2. <app-layout>
  3. <view class="title">选择发货商品<text>默认全选</text></view>
  4. <view v-if="detail.detail.length > 0" class="goods-list">
  5. <view class="dir-left-nowrap cross-center goods-item" v-for="item in detail.detail" :key="item.id">
  6. <image class="active-icon" style="background-color: #E2E2E2" v-if="item.choose == 2 && order_refund_id == 0" src="/static/image/icon/form-er.png"></image>
  7. <image v-else-if="item.choose" class="active-icon" @click='chooseAddress(item)' src="./../image/active.png"></image>
  8. <image class="active-icon" v-else @click='chooseAddress(item)' src="/static/image/icon/form-er.png"></image>
  9. <view class="dir-left-nowrap goods">
  10. <image class="goods-img" :src="item.goods_info.goods_attr.pic_url ? item.goods_info.goods_attr.pic_url : item.goods_info.goods_attr.cover_pic"></image>
  11. <view class="goods-info">
  12. <view class="t-omit-two goods-name">{{item.goods_info.goods_attr.name}}</view>
  13. <view class="goods-attr t-omit">
  14. <text v-for="(attr,index) in item.goods_info.attr_list" :key="index">{{attr.attr_group_name}}:{{attr.attr_name}}</text>
  15. </view>
  16. <view class="main-between cross-bottom">
  17. <view class="goods-num">x{{item.num}}</view>
  18. <view>¥{{item.total_price}}</view>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="title">填写物流信息</view>
  25. <view class="input-list">
  26. <view class="main-between input-item">
  27. <view class='label'>选择发货方式</view>
  28. <view class="type dir-left-nowrap">
  29. <view @click="toggleExpress(1)" :class="is_express == 1 ? 'active': ''">快递配送</view>
  30. <view @click="toggleExpress(0)" :class="is_express == 0 ? 'active': ''">无需物流</view>
  31. </view>
  32. </view>
  33. <view v-if="is_express == 1" class="dir-left-nowrap input-item">
  34. <view class='label'>快递公司</view>
  35. <view @click='toPick' width="width:30%;" class="dir-right-nowrap cross-center">
  36. <image class="to-more" src='/static/image/icon/arrow-right.png'></image>
  37. <text>{{express}}</text>
  38. </view>
  39. </view>
  40. <view v-if="is_express == 1" class="dir-left-nowrap input-item" style='position:relative'>
  41. <view class='label'>快递单号</view>
  42. <input class="express-no" v-model="express_no"></input>
  43. <text v-if="id > 0" @click="getExpressNo" class='get'>获取面单</text>
  44. </view>
  45. <view class="dir-left-nowrap input-item" v-if="express == '京东物流' && is_express == 1">
  46. <view class='label'>商家编码</view>
  47. <input v-model="customer_name"></input>
  48. </view>
  49. <view v-if="is_express == 1" class="dir-left-nowrap input-item">
  50. <view class='label'>收件人邮编</view>
  51. <input type="number" v-model="code"></input>
  52. </view>
  53. <view v-if="is_express == 1" class="dir-left-nowrap input-item">
  54. <view class='label'>商家留言</view>
  55. <input v-model="words"></input>
  56. </view>
  57. <view v-if="is_express == 0" class="dir-left-nowrap input-item">
  58. <view class='label'>物流内容</view>
  59. <input placeholder="请输入物流内容" v-model="express_content"></input>
  60. </view>
  61. </view>
  62. <button @click="saveAddress" class='address-bottom'>确认发货</button>
  63. <!-- 选择列表 -->
  64. <view class="dialog" v-if="dialog">
  65. <view class="picker-list">
  66. <view class="main-between picker-header">
  67. <view @click="toPick(2)">取消</view>
  68. <view @click="toPick(1)">确定</view>
  69. </view>
  70. <picker-view indicator-style="height: 36px;" class="pick" :value="[index]" @change="bindChange">
  71. <picker-view-column>
  72. <view v-for="item in list" class="pick-view" :key="item.name">{{item.name}}</view>
  73. </picker-view-column>
  74. </picker-view>
  75. </view>
  76. </view>
  77. </app-layout>
  78. </template>
  79. <script>
  80. import { mapState } from "vuex";
  81. export default {
  82. data() {
  83. return {
  84. express_no: '',
  85. express: '',
  86. customer_name: '',
  87. express_content: '',
  88. code: '',
  89. words: '',
  90. list: [],
  91. detail: {},
  92. dialog: false,
  93. id: '',
  94. value: 0,
  95. is_express: 1,
  96. is_send: 0,
  97. order_refund_id: 0,
  98. express_single: {},
  99. }
  100. },
  101. computed: {
  102. ...mapState({
  103. theme: state => state.mallConfig.theme,
  104. userInfo: state => state.user.info,
  105. adminImg: state => state.mallConfig.__wxapp_img.app_admin,
  106. })
  107. },
  108. methods: {
  109. chooseAddress(item) {
  110. item.choose = !item.choose;
  111. this.$forceUpdate();
  112. },
  113. toggleExpress(item) {
  114. this.is_express = item;
  115. },
  116. bindChange(e) {
  117. let index = e.detail.value[0]
  118. this.express = this.list[index].name
  119. },
  120. toPick() {
  121. let that = this;
  122. that.customer_name = '';
  123. that.list.forEach(function(row, index) {
  124. if (that.list[index].name == that.express) {
  125. if (that.list[index].name == '京东物流' || that.list[index].name == '京东快运') {
  126. that.getCustomer();
  127. }
  128. that.value = index;
  129. }
  130. })
  131. that.dialog = !that.dialog;
  132. },
  133. getExpressNo() {
  134. let that = this;
  135. uni.showLoading({
  136. title: '加载中...'
  137. });
  138. that.$request({
  139. url: that.$api.app_admin.print,
  140. data: {
  141. express: that.express,
  142. code: that.code,
  143. order_id: that.id
  144. },
  145. }).then(response=>{
  146. uni.hideLoading();
  147. if(response.code == 0) {
  148. that.express_no = response.data.Order.LogisticCode;
  149. that.express_single = response.data.express_single
  150. }else {
  151. uni.showToast({
  152. title: response.msg,
  153. icon: 'none',
  154. duration: 1000
  155. });
  156. }
  157. }).catch(response => {
  158. uni.hideLoading();
  159. });
  160. },
  161. getCustomer() {
  162. let that = this;
  163. uni.showLoading({
  164. title: '加载中...'
  165. });
  166. that.$request({
  167. url: that.$api.order.customer,
  168. data: {
  169. keyword: that.express
  170. },
  171. }).then(response=>{
  172. uni.hideLoading();
  173. if(response.code == 0) {
  174. that.customer_name = response.data.customer_account;
  175. }else {
  176. uni.showToast({
  177. title: response.msg,
  178. icon: 'none',
  179. duration: 1000
  180. });
  181. }
  182. }).catch(response => {
  183. uni.hideLoading();
  184. });
  185. },
  186. getExpress() {
  187. let that = this;
  188. uni.showLoading({
  189. title: '加载中...'
  190. });
  191. that.$request({
  192. url: that.$api.app_admin.express
  193. }).then(response=>{
  194. uni.hideLoading();
  195. if(response.code == 0) {
  196. that.list = response.data.list;
  197. that.getList();
  198. }else {
  199. uni.showToast({
  200. title: response.msg,
  201. icon: 'none',
  202. duration: 1000
  203. });
  204. }
  205. }).catch(response => {
  206. uni.hideLoading();
  207. });
  208. },
  209. getList() {
  210. let that = this;
  211. uni.showLoading({
  212. title: '加载中...'
  213. });
  214. that.$request({
  215. url: that.$api.app_admin.detail,
  216. data: {
  217. order_id: that.id
  218. },
  219. method: 'post'
  220. }).then(response=>{
  221. uni.hideLoading();
  222. if(response.code == 0) {
  223. that.detail = response.data.order;
  224. for(let i in that.detail.detail) {
  225. that.detail.detail[i].choose = true;
  226. }
  227. if(that.detail.detailExpress.length > 0) {
  228. that.detail.detail.forEach( row => {
  229. for(let i in that.detail.detailExpress) {
  230. for(let x in that.detail.detailExpress[i].expressRelation) {
  231. if(that.detail.detailExpress[i].expressRelation[x].order_detail_id == row.id) {
  232. row.choose = 2;
  233. }
  234. }
  235. }
  236. })
  237. }
  238. if(that.is_send > 0) {
  239. that.express = response.data.order.express;
  240. that.express_no = response.data.order.express_no;
  241. that.customer_name = response.data.order.customer_name;
  242. that.code = '';
  243. that.words = response.data.order.merchant_remark;
  244. if(response.data.order.code > 0) {
  245. that.code = response.data.order.code
  246. }
  247. } else {
  248. that.express = that.list[0].name
  249. }
  250. }else {
  251. uni.showToast({
  252. title: response.msg,
  253. icon: 'none',
  254. duration: 1000
  255. });
  256. }
  257. }).catch(response => {
  258. uni.hideLoading();
  259. });
  260. },
  261. saveAddress: function (e) {
  262. let that = this;
  263. if (that.is_express == 1 && !that.express_no) {
  264. uni.showToast({
  265. title: '快递单号不得为空',
  266. icon: 'none',
  267. duration: 1000,
  268. });
  269. return;
  270. }
  271. let id_list = [];
  272. for(let i in that.detail.detail) {
  273. if(that.detail.detail[i].choose && that.detail.detail[i].choose != 2) {
  274. id_list.push(that.detail.detail[i].id)
  275. }
  276. }
  277. if (id_list.length == 0 && that.order_refund_id == 0) {
  278. uni.showToast({
  279. title: '请选择发货商品',
  280. icon: 'none',
  281. duration: 1000,
  282. });
  283. return;
  284. }
  285. uni.showLoading({
  286. title: '提交中...'
  287. });
  288. let para = {
  289. is_express: 1,
  290. order_id: that.id,
  291. express_no: that.express_no,
  292. express: that.express,
  293. code: that.code,
  294. customer_name: that.customer_name,
  295. merchant_remark: that.words,
  296. express_content: '',
  297. order_detail_id: JSON.stringify(id_list),
  298. express_single_id: that.express_single.id ? that.express_single.id : 0,
  299. }
  300. if(that.is_express == 0) {
  301. para = {
  302. is_express: 2,
  303. order_id: that.id,
  304. express_content: that.express_content,
  305. order_detail_id: JSON.stringify(id_list)
  306. }
  307. }
  308. if(that.order_refund_id > 0) {
  309. that.$request({
  310. url: that.$api.app_admin.refund_handle,
  311. method: "POST",
  312. data: {
  313. is_express: 1,
  314. type: 2,
  315. is_agree: 1,
  316. order_refund_id: that.order_refund_id,
  317. express_no: that.express_no,
  318. express: that.express,
  319. merchant_remark: that.words,
  320. }
  321. }).then(response => {
  322. uni.hideLoading();
  323. if (response.code == 0) {
  324. let msg = response.msg;
  325. uni.showToast({
  326. title: msg,
  327. duration: 1000,
  328. icon: 'success',
  329. mask: false
  330. });
  331. setTimeout(function(){
  332. uni.navigateBack();
  333. },500)
  334. } else {
  335. uni.showToast({
  336. title: response.msg,
  337. icon: 'none',
  338. duration: 1000
  339. });
  340. }
  341. }).catch(response => {
  342. uni.hideLoading();
  343. uni.showToast({
  344. title: response,
  345. icon: 'none',
  346. duration: 1000
  347. });
  348. });
  349. }else {
  350. that.$request({
  351. url: that.$api.app_admin.send,
  352. method: "POST",
  353. data: para
  354. }).then(response => {
  355. uni.hideLoading();
  356. if (response.code == 0) {
  357. let msg = response.msg;
  358. if(that.is_send == 2) {
  359. msg = '修改成功'
  360. }
  361. uni.showToast({
  362. title: msg,
  363. duration: 1000,
  364. icon: 'success',
  365. mask: false
  366. });
  367. setTimeout(function(){
  368. uni.navigateBack();
  369. },500)
  370. } else {
  371. uni.showToast({
  372. title: response.msg,
  373. icon: 'none',
  374. duration: 1000
  375. });
  376. }
  377. }).catch(response => {
  378. uni.hideLoading();
  379. uni.showToast({
  380. title: response,
  381. icon: 'none',
  382. duration: 1000
  383. });
  384. });
  385. }
  386. },
  387. },
  388. onLoad(options) {
  389. let that = this;
  390. if (options.id > 0) {
  391. that.id = options.id
  392. }
  393. if (options.order_refund_id > 0) {
  394. that.order_refund_id = options.order_refund_id
  395. }
  396. that.getExpress();
  397. if (options.is_send > 0) {
  398. that.is_send = options.is_send
  399. }
  400. }
  401. }
  402. </script>
  403. <style scoped lang="scss">
  404. .title {
  405. padding: #{28rpx} #{24rpx} #{24rpx};
  406. font-size: #{28rpx};
  407. color: #353535;
  408. text {
  409. margin-left: #{16rpx};
  410. color: #999999;
  411. }
  412. }
  413. .goods-list {
  414. background-color: #fff;
  415. margin: 0 #{24rpx} #{28rpx};
  416. padding: #{32rpx} #{24rpx};
  417. border-radius: #{16rpx};
  418. .goods-item {
  419. margin-top: #{24rpx};
  420. }
  421. .goods-item:first-of-type {
  422. margin-top: 0;
  423. }
  424. .active-icon {
  425. height: #{36rpx};
  426. width: #{36rpx};
  427. border-radius: #{18rpx};
  428. margin-right: #{24rpx};
  429. }
  430. .goods {
  431. width: #{600rpx};
  432. }
  433. .goods-img {
  434. flex-shrink: 0;
  435. width: #{160rpx};
  436. height: #{160rpx};
  437. margin-right: #{20rpx};
  438. }
  439. .goods-info {
  440. font-size: #{24rpx};
  441. width: #{414rpx};
  442. color: #353535;
  443. .goods-name {
  444. height: #{64rpx};
  445. margin-top: #{5rpx};
  446. width: #{414rpx};
  447. }
  448. .goods-attr {
  449. color: #999999;
  450. width: 95%;
  451. margin-top: #{18rpx};
  452. margin-bottom: #{12rpx};
  453. text {
  454. margin-right: #{5rpx};
  455. }
  456. }
  457. .goods-num {
  458. color: #999999;
  459. }
  460. }
  461. }
  462. .pick {
  463. width: 100%;
  464. height: #{440rpx}
  465. }
  466. .pick-view {
  467. line-height: #{72rpx};
  468. text-align:center;
  469. color:#446dfd;
  470. font-size: #{32rpx};
  471. }
  472. .express-no {
  473. padding-right: #{180rpx};
  474. }
  475. .address-bottom {
  476. width: #{702rpx};
  477. height: #{80rpx};
  478. line-height: #{80rpx};
  479. border-radius: #{40rpx};
  480. padding: 0;
  481. text-align: center;
  482. margin: #{40rpx} auto;
  483. color: #fff;
  484. z-index: 7;
  485. font-size: #{28rpx};
  486. background-color: #446dfd;
  487. }
  488. .to-more {
  489. height: #{24rpx};
  490. width: #{12rpx};
  491. margin-left: #{10rpx};
  492. }
  493. .input-list {
  494. background-color: #fff;
  495. margin: 0 #{24rpx};
  496. border-radius: #{16rpx};
  497. padding: 0 #{24rpx};
  498. .input-item {
  499. border-top: #{1rpx} solid #eee;
  500. padding: #{24rpx} 0;
  501. height: #{96rpx};
  502. font-size: #{28rpx};
  503. color: #495060;
  504. .type {
  505. width: #{328rpx};
  506. view {
  507. padding: 0 #{20rpx};
  508. height: #{48rpx};
  509. line-height: #{48rpx};
  510. margin-left: #{16rpx};
  511. background-color: #fff;
  512. border-radius: #{26rpx};
  513. border: #{2rpx} solid #e2e2e2;
  514. color: #666666;
  515. display: inline-block;
  516. width: auto;
  517. font-size: #{26rpx};
  518. }
  519. .active {
  520. background-color: #446dfd;
  521. border: 0;
  522. color: #fff;
  523. }
  524. }
  525. .label {
  526. width: #{200rpx};
  527. height: #{48rpx};
  528. line-height: #{48rpx};
  529. }
  530. input {
  531. width: #{550rpx};
  532. height: #{48rpx};
  533. line-height: #{48rpx};
  534. font-size: #{28rpx};
  535. }
  536. view {
  537. width: #{550rpx};
  538. height: #{48rpx};
  539. line-height: #{48rpx};
  540. font-size: #{28rpx};
  541. }
  542. }
  543. .input-item:first-of-type {
  544. border-top: 0;
  545. }
  546. }
  547. .dialog {
  548. position: fixed;
  549. height: 100%;
  550. width: 100%;
  551. bottom: #{96rpx};
  552. left: 0;
  553. z-index: 10;
  554. background-color: rgba(0, 0, 0, .3);
  555. }
  556. .picker-list {
  557. background-color: #fff;
  558. padding-top: #{20rpx};
  559. position: fixed;
  560. bottom: #{96rpx};
  561. left: 0;
  562. width: 100%;
  563. }
  564. .picker-header {
  565. padding: 0 #{24rpx};
  566. color: #446dfd;
  567. font-size: #{32rpx};
  568. }
  569. .get {
  570. width: #{160rpx};
  571. height: #{48rpx};
  572. line-height: #{48rpx};
  573. text-align: center;
  574. border: #{1rpx} solid #446dfd;
  575. border-radius: #{24rpx};
  576. position: absolute;
  577. top: #{20rpx};
  578. right: 0;
  579. display: block;
  580. color: #446dfd;
  581. }
  582. </style>