index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <!-- 已收货查看选择商品物流 -->
  5. <view class="first" v-if="type == 'order'">
  6. <view class="first_1">
  7. <tabs :tabs="goodstabs" @tabsChange="goodstabsChange"></tabs>
  8. </view>
  9. </view>
  10. <!-- 售后,尊荣商品查看物流 -->
  11. <view class="first" v-else></view>
  12. <view class="second">
  13. <tabs :tabs="tabs" @tabsChange="tabsChange">
  14. <view class="tabsList">
  15. <view class="second_1">
  16. <view class="second_1_1">
  17. <text>订单状态:</text>
  18. <text>{{is_check}}</text>
  19. </view>
  20. <view class="second_1_1">
  21. <text>物流单号:</text>
  22. <text>{{no}}</text>
  23. </view>
  24. </view>
  25. <view class="second_2">
  26. <uni-section title="物流记录" type="line" padding>
  27. <uni-steps :options="list" active-color="#007AFF" :active="active" direction="column" />
  28. </uni-section>
  29. </view>
  30. </view>
  31. </tabs>
  32. </view>
  33. </view>
  34. </view>
  35. </mobile-frame>
  36. </template>
  37. <script>
  38. import tabs from '@/components/tabs/index.vue';
  39. export default {
  40. components: {
  41. tabs
  42. },
  43. data() {
  44. return {
  45. id: '',
  46. // 类型
  47. type: '',
  48. // 商品选择
  49. goods: {},
  50. // 标签页
  51. tabs: {
  52. active: '',
  53. menu: []
  54. },
  55. goodstabs: {
  56. active: '',
  57. menu: []
  58. },
  59. user: {},
  60. info: {},
  61. is_check: '',
  62. no: '',
  63. list: []
  64. };
  65. },
  66. onLoad: function(e) {
  67. const that = this;
  68. that.$set(that, `id`, e.id || '');
  69. that.$set(that, `type`, e.type || '');
  70. that.watchLogin()
  71. },
  72. methods: {
  73. watchLogin() {
  74. const that = this;
  75. uni.getStorage({
  76. key: 'token',
  77. success: function(res) {
  78. let user = that.$jwt(res.data);
  79. if (user) that.$set(that, `user`, user);
  80. that.searchInfo();
  81. }
  82. })
  83. },
  84. // 查商品详情
  85. async searchInfo() {
  86. const that = this;
  87. if (that.id) {
  88. let res;
  89. if (that.type == 'integral') {
  90. res = await that.$api(`/zrOrder/${that.id}`, `GET`, {}, `integral`)
  91. } else if (that.type == 'groupOrder') {
  92. res = await that.$api(`/groupOrder/${that.id}`, `GET`, {}, `group`)
  93. } else if (that.type == 'afterSale') {
  94. res = await that.$api(`/afterSale/${that.id}`, `GET`)
  95. that.$set(that.tabs, `active`, 'shop')
  96. that.$set(that.tabs, `menu`, [{
  97. title: '店铺物流',
  98. active: 'shop',
  99. }, {
  100. title: '用户物流',
  101. active: 'customer',
  102. }])
  103. } else if (that.type == 'groupAfterSale') {
  104. res = await that.$api(`/groupAfterSale/${that.id}`, `GET`, {}, 'group')
  105. that.$set(that.tabs, `active`, 'shop')
  106. that.$set(that.tabs, `menu`, [{
  107. title: '店铺物流',
  108. active: 'shop',
  109. }, {
  110. title: '用户物流',
  111. active: 'customer',
  112. }])
  113. } else {
  114. res = await that.$api(`/orderDetail/${that.id}`, 'GET')
  115. }
  116. if (res.errcode == '0') {
  117. if (that.type == 'order') {
  118. for (let [index, val] of res.data.goods.entries()) {
  119. let num = index + 1
  120. val.title = `物流` + num;
  121. val.active = val.goods._id;
  122. }
  123. that.$set(that.tabs, `active`, res.data.goods[0].goods._id)
  124. that.$set(that.goodstabs, `menu`, res.data.goods)
  125. }
  126. that.$set(that, `info`, res.data);
  127. if (that.type != 'order') that.search();
  128. if (that.type == 'order') that.goodstabsChange(res.data.goods[0].goods._id, '1')
  129. } else {
  130. uni.showToast({
  131. title: res.errmsg,
  132. icon: 'none'
  133. })
  134. }
  135. }
  136. },
  137. // 查物流信息
  138. async search() {
  139. const that = this;
  140. if (that.type == 'afterSale') {
  141. let arr = await that.$api(`/afterSale/getTransportInfo/${that.info.id}`, `GET`)
  142. if (arr.errcode == '0') {
  143. if (that.tabs.active == 'shop') {
  144. that.$set(that, `is_check`, arr.data?.shop.is_check);
  145. let list = arr.data?.shop.list.map((i) => ({
  146. desc: i.time,
  147. title: i.context
  148. }))
  149. that.$set(that, `list`, list);
  150. that.$set(that, `no`, arr.data?.shop.no);
  151. } else {
  152. that.$set(that, `is_check`, arr.data?.customer.is_check);
  153. let list = arr.data?.customer.list.map((i) => ({
  154. desc: i.time,
  155. title: i.context
  156. }))
  157. that.$set(that, `list`, list);
  158. that.$set(that, `no`, arr.data?.customer.no);
  159. }
  160. } else {
  161. uni.showToast({
  162. title: res.errmsg,
  163. icon: 'none'
  164. })
  165. }
  166. } else {
  167. if (that.type == 'integral') {
  168. let res = await that.$api(`/zrOrder/sot/${that.info._id}`, `GET`, {}, `integral`);
  169. if (res.errcode == '0') {
  170. that.$set(that, `is_check`, res.data.is_check);
  171. let list = res.data.list.map((i) => ({
  172. desc: i.time,
  173. title: i.context
  174. }))
  175. that.$set(that, `list`, list);
  176. that.$set(that, `no`, res.data.no);
  177. } else {
  178. uni.showToast({
  179. title: res.errmsg,
  180. icon: 'none'
  181. })
  182. }
  183. } else if (that.type == 'groupAfterSale') {
  184. let arr = await that.$api(`/orderOthers/afterSale/transport`, `POST`, {
  185. id: that.id
  186. }, `group`);
  187. if (arr.errcode == '0') {
  188. if (that.tabs.active == 'shop') {
  189. that.$set(that, `is_check`, arr.data?.shop.is_check);
  190. let list = arr.data?.shop.list.map((i) => ({
  191. desc: i.time,
  192. title: i.context
  193. }))
  194. that.$set(that, `list`, list);
  195. that.$set(that, `no`, arr.data?.shop.no);
  196. } else {
  197. that.$set(that, `is_check`, arr.data?.customer.is_check);
  198. let list = arr.data?.customer.list.map((i) => ({
  199. desc: i.time,
  200. title: i.context
  201. }))
  202. that.$set(that, `list`, list);
  203. that.$set(that, `no`, arr.data?.customer.no);
  204. }
  205. } else {
  206. uni.showToast({
  207. title: res.errmsg,
  208. icon: 'none'
  209. })
  210. }
  211. } else if (that.type == 'groupOrder') {
  212. let res = await that.$api(`/orderOthers/transport`, `POST`, {
  213. order: that.id
  214. }, `group`);
  215. if (res.errcode == '0') {
  216. that.$set(that, `is_check`, res?.data[0].is_check);
  217. let list = res?.data[0].list.map((i) => ({
  218. desc: i.time,
  219. title: i.context
  220. }))
  221. that.$set(that, `list`, list);
  222. that.$set(that, `no`, res?.data[0].no);
  223. } else {
  224. uni.showToast({
  225. title: res.errmsg,
  226. icon: 'none'
  227. })
  228. }
  229. } else {
  230. let data = that.tabs.menu.find((i) => i.no == that.tabs.active);
  231. if (data) {
  232. that.$set(that, `is_check`, data.is_check);
  233. let list = data.list.map((i) => ({
  234. desc: i.time,
  235. title: i.context
  236. }))
  237. that.$set(that, `list`, list);
  238. that.$set(that, `no`, data.no);
  239. } else {
  240. uni.showToast({
  241. title: '暂无物流信息!',
  242. icon: 'none'
  243. })
  244. }
  245. }
  246. }
  247. },
  248. // 选择指定商品查信息
  249. async goodstabsChange(e, type) {
  250. const that = this;
  251. let active = '';
  252. if (type == '1') active = e
  253. else active = e.active
  254. that.$set(that.goodstabs, `active`, active)
  255. let res = await that.$api(`/orderDetail/sot`, `POST`, {
  256. id: that.info._id,
  257. goods_id: active
  258. });
  259. if (res.errcode == '0') {
  260. for (let [index, item] of res.data.entries()) {
  261. item.title = `物流` + index
  262. item.active = item.no
  263. }
  264. that.$set(that.tabs, `active`, res?.data[0]?.no)
  265. that.$set(that.tabs, `menu`, res.data)
  266. that.search();
  267. } else {
  268. uni.showToast({
  269. title: res.errmsg,
  270. icon: 'none'
  271. })
  272. }
  273. },
  274. // 选择选项卡
  275. tabsChange(e) {
  276. const that = this;
  277. that.$set(that.tabs, `active`, e.active)
  278. that.search()
  279. },
  280. }
  281. }
  282. </script>
  283. <style lang="scss">
  284. .main {
  285. display: flex;
  286. flex-direction: column;
  287. width: 100vw;
  288. height: 100vh;
  289. .first {
  290. position: relative;
  291. width: 100vw;
  292. height: 100vh;
  293. background-color: #ff0000;
  294. .first_1 {
  295. width: 96vw;
  296. padding: 2vw;
  297. .picker {
  298. border: 1px solid #3333;
  299. border-radius: 5px;
  300. padding: 2vw;
  301. background: #fff;
  302. }
  303. }
  304. .first_2 {
  305. display: flex;
  306. width: 92vw;
  307. background-color: #fff;
  308. padding: 2vw;
  309. margin: 0 2vw;
  310. border-radius: 7px;
  311. .image {
  312. width: 22vw;
  313. height: 22vw;
  314. }
  315. .other {
  316. width: 65vw;
  317. padding: 0 0 0 2vw;
  318. .name {
  319. font-size: 16px;
  320. font-weight: bold;
  321. }
  322. .other_1 {
  323. text {
  324. font-size: 13px;
  325. color: #858585;
  326. }
  327. text:last-child {
  328. color: #000000;
  329. }
  330. }
  331. }
  332. }
  333. }
  334. .second {
  335. position: absolute;
  336. bottom: 0;
  337. width: 92vw;
  338. height: 60vh;
  339. overflow-y: auto;
  340. background: #fff;
  341. margin: 0 2vw;
  342. border-top-left-radius: 5px;
  343. border-top-right-radius: 5px;
  344. padding: 2vw;
  345. .tabsList {
  346. .second_1 {
  347. margin: 0 0 2vw 0;
  348. .second_1_1 {
  349. padding: 1vw 0;
  350. }
  351. }
  352. }
  353. }
  354. }
  355. .uni-section .uni-section-header {
  356. padding: 1vw !important;
  357. }
  358. .uni-section .uni-section-content {
  359. padding: 0 !important;
  360. }
  361. </style>