send-goods.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. <template>
  2. <view class="send_box">
  3. <view class="guide_box" v-if="showGuide" @click="showGuide = false">
  4. <image src="../../static/imgs/shop/express.png" mode="" class="express_img"></image>
  5. </view>
  6. <view class="send_goods">
  7. <view>
  8. <view class="label">
  9. <text>快递单号</text>
  10. <text>*</text>
  11. </view>
  12. <view class="flexB scan_box">
  13. <input type="text" placeholder="在此输入快递单号" placeholder-class="place" v-model="num" />
  14. <view class="scan_btn flexCC" @click="scanCode()">快速录入单号</view>
  15. </view>
  16. </view>
  17. <view>
  18. <view class="label">
  19. <text>快递公司</text>
  20. <text>*</text>
  21. </view>
  22. <picker @change="bindPickerChange" :value="index" :range="logs" :range-key="'name'">
  23. <view class="picker flexB">
  24. <view class="inp_box" :style="{ color: logsName ? '#333' : '#999' }">
  25. {{ logsName ? logsName : '请选择快递公司' }}
  26. </view>
  27. <text class="iconfont iconzhcc_xiangxiajiantou"></text>
  28. </view>
  29. </picker>
  30. </view>
  31. <view v-if="logsName == '顺丰速运' || logsName == '顺丰快递'">
  32. <view class="label">
  33. <text>收货人手机号</text>
  34. <text>*</text>
  35. </view>
  36. <input type="text" placeholder="在此输入收货人手机号" placeholder-class="place" v-model="express_phone" />
  37. </view>
  38. <view>
  39. <view class="label">
  40. <text>发货日期</text>
  41. <text>*</text>
  42. </view>
  43. <picker @change="bindDateChange" mode="date" :value="date" :start="startDay">
  44. <view class="picker flexB">
  45. <view class="inp_box">{{ date }}</view>
  46. <text class="iconfont iconzhcc_xiangxiajiantou"></text>
  47. </view>
  48. </picker>
  49. </view>
  50. <view class="sub_btn" @click="submit">提交</view>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. import {
  56. getLogsCode,
  57. addLogs,
  58. getAds,
  59. location,
  60. getExpress
  61. } from '../../apis/shop.js';
  62. // var jweixin = require('jweixin-module');
  63. export default {
  64. data() {
  65. const currentDate = this.getDate({
  66. format: true
  67. });
  68. return {
  69. num: '', //物流单号
  70. logs: [], //物流名称选项
  71. logsName: '', //物流公司名称
  72. logsCode: '', //物流公司编码
  73. order_no: '', //订单编号
  74. index: 0, //选择物流名称
  75. date: currentDate, //发货日期
  76. startDay: '2020-01-01',
  77. user_id: '',
  78. address: '', //从下个页面选择的地址
  79. defaultAds: '', //获取的默认地址
  80. ads: {
  81. province: '',
  82. city: '',
  83. area: '',
  84. location: ''
  85. },
  86. userName: '',
  87. userPhone: '',
  88. userAds: '',
  89. express_phone: '', //发货时候如果是顺丰速运填写用户手机号
  90. showGuide: true
  91. };
  92. },
  93. onLoad(ops) {
  94. this.order_no = ops.order_no;
  95. this.user_id = ops.user_id;
  96. this.getCode();
  97. },
  98. methods: {
  99. //扫码获取单号
  100. scanCode() {
  101. this.showGuide = false;
  102. uni.scanCode({
  103. success: res => {
  104. let code = res.result;
  105. console.log(res, 2222)
  106. this.getExpress(code);
  107. },
  108. fail: err => {
  109. console.log(err, 1111)
  110. uni.showModal({
  111. content: '扫码失败',
  112. showCancel: false
  113. })
  114. }
  115. });
  116. },
  117. //根据单号获取物流公司
  118. getExpress(expressCode) {
  119. uni.showLoading({
  120. title: '识别中...',
  121. mask: true
  122. })
  123. getExpress({
  124. expressCode
  125. }).then(res => {
  126. if (res.code == 200) {
  127. if (!res.data.Success) {
  128. uni.showModal({
  129. content: '请重新扫码或手动选择输入',
  130. showCancel: false
  131. });
  132. return false;
  133. }
  134. this.num = res.data.LogisticCode;
  135. if (res.data.Shippers) {
  136. const {
  137. ShipperName,
  138. ShipperCode
  139. } = res.data.Shippers[0];
  140. this.logsName = ShipperName;
  141. this.logsCode = ShipperCode;
  142. } else {
  143. uni.showModal({
  144. content: '请重新扫码或手动选择输入',
  145. showCancel: false
  146. });
  147. this.logsName = this.logsCode = '';
  148. }
  149. } else {
  150. uni.showModal({
  151. content: res.data || '获取数据失败',
  152. showCancel: false
  153. });
  154. }
  155. uni.hideLoading();
  156. }).catch(err => {
  157. uni.hideLoading();
  158. })
  159. },
  160. /*添加地址*/
  161. addressList() {
  162. uni.navigateTo({
  163. url: '../ads-list/ads-list?user_id=' + this.user_id
  164. });
  165. },
  166. /*获取物流的*/
  167. getCode() {
  168. getLogsCode().then(res => {
  169. if (res.code == 200) {
  170. let list = res.data;
  171. for (let key in list) {
  172. this.logs.push({
  173. code: key,
  174. name: list[key]
  175. });
  176. }
  177. } else {
  178. uni.showModal({
  179. content: res.data || '获取物流公司失败',
  180. showCancel: false
  181. });
  182. }
  183. });
  184. },
  185. /*选择物流公司*/
  186. bindPickerChange(e) {
  187. let idx = e.detail.value;
  188. this.index = idx;
  189. this.logsName = this.logs[idx].name;
  190. this.logsCode = this.logs[idx].code;
  191. },
  192. /*选择日期*/
  193. bindDateChange(e) {
  194. this.date = e.target.value;
  195. console.log(this.date);
  196. },
  197. getDate(type) {
  198. const date = new Date();
  199. let year = date.getFullYear();
  200. let month = date.getMonth() + 1;
  201. let day = date.getDate();
  202. if (type === 'start') {
  203. year = year - 60;
  204. } else if (type === 'end') {
  205. year = year + 2;
  206. }
  207. month = month > 9 ? month : '0' + month;
  208. day = day > 9 ? day : '0' + day;
  209. return `${year}-${month}-${day}`;
  210. },
  211. submit() {
  212. // if (!this.address.id && !this.defaultAds.id) {
  213. // uni.showModal({
  214. // content: '发货地址不能为空',
  215. // showCancel: false
  216. // });
  217. // return false;
  218. // }
  219. if (!this.num) {
  220. uni.showModal({
  221. content: '物流单号不能为空',
  222. showCancel: false
  223. });
  224. return false;
  225. }
  226. if (this.logsName == '请选择物流公司') {
  227. uni.showModal({
  228. content: '物流名称不能为空',
  229. showCancel: false
  230. });
  231. return false;
  232. }
  233. if (this.logsName == '顺丰速运' && !this.express_phone) {
  234. uni.showModal({
  235. content: '请输入收货人手机号',
  236. showCancel: false
  237. });
  238. return false;
  239. }
  240. if (!this.date) {
  241. uni.showModal({
  242. content: '发货日期不能为空',
  243. showCancel: false
  244. });
  245. return false;
  246. }
  247. uni.showLoading({
  248. title: '提交中....'
  249. });
  250. addLogs({
  251. order_no: this.order_no,
  252. express_no: this.num,
  253. express_code: this.logsCode,
  254. express_company: this.logsName,
  255. express_time: this.date,
  256. address_id: this.address.id || this.defaultAds.id || '',
  257. express_phone: this.express_phone
  258. })
  259. .then(res => {
  260. if (res.code == 200) {
  261. uni.showModal({
  262. content: '发货成功',
  263. showCancel: false,
  264. success: res => {
  265. if (res.confirm) {
  266. uni.reLaunch({
  267. url: '../order-manage/order-manage?status=' + 3
  268. });
  269. }
  270. }
  271. });
  272. } else {
  273. uni.showModal({
  274. content: res.data || '发货失败',
  275. showCancel: false
  276. });
  277. }
  278. uni.hideLoading();
  279. })
  280. .catch(err => {
  281. uni.hideLoading();
  282. });
  283. }
  284. }
  285. };
  286. </script>
  287. <style lang="scss" scoped>
  288. .guide_box {
  289. width: 100vw;
  290. height: 100vh;
  291. position: fixed;
  292. top: 0;
  293. left: 0;
  294. background: rgba(0, 0, 0, 0.5);
  295. display: flex;
  296. flex-direction: column;
  297. align-items: center;
  298. z-index: 999;
  299. .express_img {
  300. width: 608rpx;
  301. height: 731rpx;
  302. margin-top: 20vh;
  303. }
  304. }
  305. .scan_box {
  306. width: 690rpx;
  307. background: #f9f9fb;
  308. border-radius: 8rpx;
  309. .scan_btn {
  310. width: 196rpx;
  311. height: 60rpx;
  312. background: #fff4f3;
  313. border: 2rpx solid #fb231f;
  314. border-radius: 34rpx;
  315. color: $base-color;
  316. margin-right: 10rpx;
  317. z-index: 999999;
  318. }
  319. input {
  320. width: 70%;
  321. }
  322. }
  323. .send_box {
  324. width: 100%;
  325. min-height: 100%;
  326. background: #fff;
  327. .send_goods {
  328. width: 690rpx;
  329. padding-top: 30rpx;
  330. margin: 0 auto;
  331. background-color: #fff;
  332. .label {
  333. margin: 30rpx 0;
  334. text:first-child {
  335. font-size: 32rpx;
  336. font-weight: bold;
  337. }
  338. text:last-child {
  339. font-size: 32rpx;
  340. color: $base-color;
  341. font-weight: bold;
  342. }
  343. }
  344. .picker {
  345. background: #f9f9fb;
  346. height: 88rpx;
  347. line-height: 88rpx;
  348. border-radius: 8rpx;
  349. padding: 0 30rpx;
  350. .iconfont {
  351. color: #999;
  352. }
  353. .inp_box {
  354. font-size: 30rpx;
  355. }
  356. }
  357. input {
  358. height: 88rpx;
  359. background: #f9f9fb;
  360. border-radius: 8rpx;
  361. padding-left: 30rpx;
  362. box-sizing: border-box;
  363. font-size: 30rpx;
  364. }
  365. .place {
  366. font-size: 30rpx;
  367. color: #999;
  368. }
  369. .sub_btn {
  370. margin: 60rpx auto 50rpx;
  371. }
  372. .address_box {
  373. padding: 30rpx;
  374. width: 100%;
  375. box-sizing: border-box;
  376. background-color: #f9f9fb;
  377. border-radius: 24rpx;
  378. .icondizhi1 {
  379. color: $base-color;
  380. font-size: 50rpx;
  381. vertical-align: middle;
  382. }
  383. .add_box {
  384. margin-left: 20rpx;
  385. font-size: 30rpx;
  386. color: #999;
  387. }
  388. .iconiconfontjiantou2 {
  389. color: #999;
  390. }
  391. .ads_info {
  392. margin: 0 15rpx;
  393. .shop_info {
  394. font-size: 32rpx;
  395. font-weight: bold;
  396. text:last-child {
  397. font-size: 28rpx;
  398. color: #999;
  399. }
  400. }
  401. .ads_del {
  402. margin-top: 15rpx;
  403. }
  404. }
  405. }
  406. .scan_box {
  407. width: 690rpx;
  408. background: #f9f9fb;
  409. border-radius: 8rpx;
  410. .scan_btn {
  411. width: 196rpx;
  412. height: 60rpx;
  413. background: #fff4f3;
  414. border: 2rpx solid #fb231f;
  415. border-radius: 34rpx;
  416. color: $base-color;
  417. margin-right: 10rpx;
  418. }
  419. input {
  420. width: 70%;
  421. }
  422. }
  423. }
  424. }
  425. </style>