edit-logisitics.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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="express_no" />
  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: express_company ? '#333' : '#999' }">
  25. {{ express_company ? express_company : '请选择快递公司' }}</view>
  26. <text class="iconfont iconzhcc_xiangxiajiantou"></text>
  27. </view>
  28. </picker>
  29. </view>
  30. <view v-if="express_company == '顺丰速运'">
  31. <view class="label">
  32. <text>收货人手机号</text>
  33. <text>*</text>
  34. </view>
  35. <input type="text" placeholder="在此输入收货人手机号" placeholder-class="place" v-model="express_phone" />
  36. </view>
  37. <view>
  38. <view class="label">
  39. <text>发货日期</text>
  40. <text>*</text>
  41. </view>
  42. <picker @change="bindDateChange" mode="date" :value="date" :start="startDay">
  43. <view class="picker flexB">
  44. <view class="inp_box">{{ date }}</view>
  45. <text class="iconfont iconzhcc_xiangxiajiantou"></text>
  46. </view>
  47. </picker>
  48. </view>
  49. <view class="sub_btn" @click="submit">提交</view>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. import {
  55. getLogsCode,
  56. addLogs,
  57. editLog,
  58. getExpress,
  59. location
  60. } from '../../apis/shop.js';
  61. export default {
  62. data() {
  63. return {
  64. num: '', //物流单号
  65. logs: [], //物流名称选项
  66. order_no: '', //订单编号
  67. index: 0, //选择物流名称
  68. startDay: '2020-01-01',
  69. date: '',
  70. express_phone: '', //发货时候如果是顺丰速运填写用户手机号
  71. express_company: '', //物流公司
  72. express_code: '', // 物流单号code值
  73. express_no: '', //物流单号
  74. img: '',
  75. showGuide: true
  76. };
  77. },
  78. onLoad(ops) {
  79. let data = JSON.parse(decodeURIComponent(ops.data));
  80. this.order_no = data.order_no;
  81. this.img = data.img;
  82. this.express_company = data.express_company;
  83. this.express_code = data.express_code;
  84. this.express_no = data.express_no;
  85. this.express_phone = data.express_phone;
  86. this.date = data.express_time;
  87. this.getCode();
  88. },
  89. methods: {
  90. //根据单号获取物流公司
  91. getExpress(expressCode) {
  92. getExpress({
  93. expressCode
  94. }).then(res => {
  95. if (res.code == 200) {
  96. if (!res.data.Success) {
  97. uni.showModal({
  98. content: '请重新扫码或手动选择输入',
  99. showCancel: false
  100. });
  101. return false;
  102. }
  103. this.express_no = res.data.LogisticCode;
  104. if (res.data.Shippers) {
  105. const {
  106. ShipperName,
  107. ShipperCode
  108. } = res.data.Shippers[0];
  109. this.express_company = ShipperName;
  110. this.express_code = ShipperCode;
  111. } else {
  112. uni.showModal({
  113. content: '请重新扫码或手动选择输入',
  114. showCancel: false
  115. });
  116. this.logsName = this.logsCode = '';
  117. }
  118. } else {
  119. uni.showModal({
  120. content: res.data || '获取数据失败',
  121. showCancel: false
  122. });
  123. }
  124. });
  125. },
  126. /*获取物流的*/
  127. getCode() {
  128. getLogsCode().then(res => {
  129. if (res.code == 200) {
  130. let list = res.data;
  131. for (let key in list) {
  132. this.logs.push({
  133. code: key,
  134. name: list[key]
  135. });
  136. }
  137. } else {
  138. uni.showModal({
  139. content: res.data || '获取物流公司失败',
  140. showCancel: false
  141. });
  142. }
  143. });
  144. },
  145. /*选择物流公司*/
  146. bindPickerChange(e) {
  147. let idx = e.detail.value;
  148. this.index = idx;
  149. this.express_company = this.logs[idx].name;
  150. this.express_code = this.logs[idx].code;
  151. console.log(this.express_code);
  152. },
  153. /*选择日期*/
  154. bindDateChange(e) {
  155. this.date = e.target.value;
  156. },
  157. submit() {
  158. if (!this.express_no) {
  159. uni.showModal({
  160. content: '物流单号不能为空',
  161. showCancel: false
  162. });
  163. return false;
  164. }
  165. if (this.express_company == '请选择物流公司') {
  166. uni.showModal({
  167. content: '物流名称不能为空',
  168. showCancel: false
  169. });
  170. return false;
  171. }
  172. if (this.express_company == '顺丰速运' && !this.express_phone) {
  173. uni.showModal({
  174. content: '请输入收货人手机号',
  175. showCancel: false
  176. });
  177. return false;
  178. }
  179. if (!this.date) {
  180. uni.showModal({
  181. content: '发货日期不能为空',
  182. showCancel: false
  183. });
  184. return false;
  185. }
  186. editLog({
  187. order_no: this.order_no,
  188. express_no: this.express_no,
  189. express_code: this.express_code,
  190. express_company: this.express_company,
  191. express_time: this.date,
  192. express_phone: this.express_phone
  193. }).then(res => {
  194. if (res.code == 200) {
  195. uni.showModal({
  196. content: '修改成功',
  197. showCancel: false,
  198. success: res => {
  199. if (res.confirm) {
  200. uni.reLaunch({
  201. url: '../logistics-detail/logistics-detail?order_no=' +
  202. this.order_no + '&img=' + this.img
  203. });
  204. }
  205. }
  206. });
  207. } else {
  208. uni.showModal({
  209. content: res.data || '修改失败',
  210. showCancel: false
  211. });
  212. }
  213. });
  214. }
  215. }
  216. };
  217. </script>
  218. <style lang="scss" scoped>
  219. .guide_box {
  220. width: 100vw;
  221. height: 100vh;
  222. position: fixed;
  223. top: 0;
  224. left: 0;
  225. background: rgba(0, 0, 0, 0.5);
  226. display: flex;
  227. flex-direction: column;
  228. justify-content: center;
  229. align-items: center;
  230. z-index: 999;
  231. .express_img {
  232. width: 608rpx;
  233. height: 731rpx;
  234. }
  235. }
  236. .address_box {
  237. padding: 30rpx;
  238. width: 100%;
  239. box-sizing: border-box;
  240. background-color: #f9f9fb;
  241. border-radius: 24rpx;
  242. // margin: 30rpx 0;
  243. .icondizhi1 {
  244. color: $base-color;
  245. font-size: 50rpx;
  246. vertical-align: middle;
  247. }
  248. .gray {
  249. margin-left: 20rpx;
  250. }
  251. .iconiconfontjiantou2 {
  252. color: #999;
  253. }
  254. .ads_info {
  255. margin: 0 15rpx;
  256. .shop_info {
  257. font-size: 32rpx;
  258. font-weight: bold;
  259. text:last-child {
  260. font-size: 28rpx;
  261. color: #999;
  262. }
  263. }
  264. .ads_del {
  265. margin-top: 15rpx;
  266. }
  267. }
  268. }
  269. .new_user {
  270. .ads_picker {
  271. width: 690rpx;
  272. background: #f9f9fb;
  273. padding-right: 15rpx;
  274. input {
  275. width: 92%;
  276. font-size: 28rpx;
  277. }
  278. .iconfont {
  279. color: #999;
  280. }
  281. }
  282. }
  283. .send_box {
  284. width: 100%;
  285. min-height: 100%;
  286. background: #fff;
  287. .send_goods {
  288. width: 690rpx;
  289. margin: 0 auto;
  290. padding-top: 30rpx;
  291. .label {
  292. margin: 30rpx 0;
  293. text:first-child {
  294. font-size: 32rpx;
  295. font-weight: bold;
  296. }
  297. text:last-child {
  298. font-size: 32rpx;
  299. color: $base-color;
  300. font-weight: bold;
  301. }
  302. }
  303. .scan_box {
  304. width: 690rpx;
  305. background: #f9f9fb;
  306. border-radius: 8rpx;
  307. .scan_btn {
  308. width: 196rpx;
  309. height: 60rpx;
  310. background: #fff4f3;
  311. border: 2rpx solid #fb231f;
  312. border-radius: 34rpx;
  313. color: $base-color;
  314. margin-right: 10rpx;
  315. z-index: 999999;
  316. }
  317. input {
  318. width: 70%;
  319. }
  320. }
  321. .picker {
  322. background: #f9f9fb;
  323. height: 88rpx;
  324. line-height: 88rpx;
  325. border-radius: 8rpx;
  326. padding: 0 30rpx;
  327. .iconfont {
  328. color: #999;
  329. }
  330. .inp_box {
  331. font-size: 30rpx;
  332. }
  333. }
  334. input {
  335. height: 88rpx;
  336. background: #f9f9fb;
  337. border-radius: 8rpx;
  338. padding-left: 30rpx;
  339. box-sizing: border-box;
  340. }
  341. .place {
  342. font-size: 30rpx;
  343. color: #999;
  344. }
  345. .sub_btn {
  346. margin: 60rpx auto 50rpx;
  347. }
  348. }
  349. }
  350. </style>