index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <view class="second">
  5. <tabs :tabs="tabs" @tabsChange="tabsChange">
  6. <view class="tabsList">
  7. <view class="second_1">
  8. <view class="second_1_1">
  9. <text>订单状态:</text>
  10. <text>{{is_check}}</text>
  11. </view>
  12. <view class="second_1_1">
  13. <text>物流单号:</text>
  14. <text user-select="true">{{no}}</text>
  15. </view>
  16. <view class="second_1_1" v-if="type == 'order'">
  17. <text>包含商品:</text>
  18. <text v-for="(item,index) in goods" :key="index">{{item.goods_name}};</text>
  19. </view>
  20. </view>
  21. <view class="second_2">
  22. <uni-section title="物流记录" type="line" padding>
  23. <uni-steps :options="list" active-color="#007AFF" :active="active" direction="column" />
  24. </uni-section>
  25. </view>
  26. </view>
  27. </tabs>
  28. </view>
  29. </view>
  30. </view>
  31. </mobile-frame>
  32. </template>
  33. <script>
  34. import tabs from '../components/tabs/index.vue';
  35. export default {
  36. components: {
  37. tabs
  38. },
  39. data() {
  40. return {
  41. id: '',
  42. // 类型
  43. type: '',
  44. // 商品
  45. goods: [],
  46. // 标签页
  47. tabs: {
  48. active: '',
  49. menu: []
  50. },
  51. user: {},
  52. info: {},
  53. is_check: '',
  54. no: '',
  55. list: []
  56. };
  57. },
  58. onLoad: function(e) {
  59. const that = this;
  60. that.$set(that, `id`, e.id || '');
  61. that.$set(that, `type`, e.type || '');
  62. that.watchLogin()
  63. },
  64. methods: {
  65. watchLogin() {
  66. const that = this;
  67. uni.getStorage({
  68. key: 'token',
  69. success: function(res) {
  70. let user = that.$jwt(res.data);
  71. if (user) that.$set(that, `user`, user);
  72. that.searchInfo();
  73. }
  74. })
  75. },
  76. // 查商品详情
  77. async searchInfo() {
  78. const that = this;
  79. if (that.id) {
  80. let res;
  81. if (that.type == 'integral') {
  82. res = await that.$api(`/zrOrder/${that.id}`, `GET`, {}, `integral`)
  83. } else if (that.type == 'groupOrder') {
  84. res = await that.$api(`/groupOrder/${that.id}`, `GET`, {}, `group`)
  85. } else if (that.type == 'afterSale') {
  86. res = await that.$api(`/afterSale/${that.id}`, `GET`)
  87. that.$set(that.tabs, `active`, 'shop')
  88. that.$set(that.tabs, `menu`, [{
  89. title: '店铺物流',
  90. active: 'shop',
  91. }, {
  92. title: '用户物流',
  93. active: 'customer',
  94. }])
  95. } else if (that.type == 'groupAfterSale') {
  96. res = await that.$api(`/groupAfterSale/${that.id}`, `GET`, {}, 'group')
  97. that.$set(that.tabs, `active`, 'shop')
  98. that.$set(that.tabs, `menu`, [{
  99. title: '店铺物流',
  100. active: 'shop',
  101. }, {
  102. title: '用户物流',
  103. active: 'customer',
  104. }])
  105. } else {
  106. res = await that.$api(`/orderDetail/${that.id}`, 'GET')
  107. }
  108. if (res.errcode == '0') {
  109. if (that.type == 'order') {
  110. let res = await that.$api(`/orderDetail/sot`, `POST`, {
  111. id: that.id,
  112. });
  113. if (res.errcode == '0') {
  114. for (let [index, item] of res.data.entries()) {
  115. let num = index + 1
  116. item.title = `物流编号` + num;
  117. item.active = item.no
  118. }
  119. that.$set(that, `goods`, res?.data[0]?.goods)
  120. that.$set(that.tabs, `active`, res?.data[0]?.no)
  121. that.$set(that.tabs, `menu`, res.data)
  122. } else {
  123. uni.showToast({
  124. title: res.errmsg,
  125. icon: 'none'
  126. })
  127. }
  128. }
  129. that.$set(that, `info`, res.data);
  130. that.search();
  131. } else {
  132. uni.showToast({
  133. title: res.errmsg,
  134. icon: 'none'
  135. })
  136. }
  137. }
  138. },
  139. // 查物流信息
  140. async search() {
  141. const that = this;
  142. if (that.type == 'afterSale') {
  143. let arr = await that.$api(`/afterSale/getTransportInfo/${that.info.id}`, `GET`)
  144. if (arr.errcode == '0') {
  145. if (that.tabs.active == 'shop') {
  146. that.$set(that, `is_check`, arr.data?.shop.is_check);
  147. let list = arr.data?.shop.list.map((i) => ({
  148. desc: i.time,
  149. title: i.context
  150. }))
  151. that.$set(that, `list`, list);
  152. that.$set(that, `no`, arr.data?.shop.no);
  153. } else {
  154. that.$set(that, `is_check`, arr.data?.customer.is_check);
  155. let list = arr.data?.customer.list.map((i) => ({
  156. desc: i.time,
  157. title: i.context
  158. }))
  159. that.$set(that, `list`, list);
  160. that.$set(that, `no`, arr.data?.customer.no);
  161. }
  162. } else {
  163. uni.showToast({
  164. title: res.errmsg,
  165. icon: 'none'
  166. })
  167. }
  168. } else {
  169. if (that.type == 'integral') {
  170. let res = await that.$api(`/zrOrder/sot/${that.info._id}`, `GET`, {}, `integral`);
  171. if (res.errcode == '0') {
  172. that.$set(that, `is_check`, res.data.is_check);
  173. let list = res.data.list.map((i) => ({
  174. desc: i.time,
  175. title: i.context
  176. }))
  177. that.$set(that, `list`, list);
  178. that.$set(that, `no`, res.data.no);
  179. } else {
  180. uni.showToast({
  181. title: res.errmsg,
  182. icon: 'none'
  183. })
  184. }
  185. } else if (that.type == 'groupAfterSale') {
  186. let arr = await that.$api(`/orderOthers/afterSale/transport`, `POST`, {
  187. id: that.id
  188. }, `group`);
  189. if (arr.errcode == '0') {
  190. if (that.tabs.active == 'shop') {
  191. that.$set(that, `is_check`, arr.data?.shop.is_check);
  192. let list = arr.data?.shop.list.map((i) => ({
  193. desc: i.time,
  194. title: i.context
  195. }))
  196. that.$set(that, `list`, list);
  197. that.$set(that, `no`, arr.data?.shop.no);
  198. } else {
  199. that.$set(that, `is_check`, arr.data?.customer.is_check);
  200. let list = arr.data?.customer.list.map((i) => ({
  201. desc: i.time,
  202. title: i.context
  203. }))
  204. that.$set(that, `list`, list);
  205. that.$set(that, `no`, arr.data?.customer.no);
  206. }
  207. } else {
  208. uni.showToast({
  209. title: res.errmsg,
  210. icon: 'none'
  211. })
  212. }
  213. } else if (that.type == 'groupOrder') {
  214. let res = await that.$api(`/orderOthers/transport`, `POST`, {
  215. order: that.id
  216. }, `group`);
  217. if (res.errcode == '0') {
  218. that.$set(that, `is_check`, res?.data[0].is_check);
  219. let list = res?.data[0].list.map((i) => ({
  220. desc: i.time,
  221. title: i.context
  222. }))
  223. that.$set(that, `list`, list);
  224. that.$set(that, `no`, res?.data[0].no);
  225. } else {
  226. uni.showToast({
  227. title: res.errmsg,
  228. icon: 'none'
  229. })
  230. }
  231. } else {
  232. let data = that.tabs.menu.find((i) => i.no == that.tabs.active);
  233. if (data) {
  234. that.$set(that, `is_check`, data.is_check);
  235. let list = data.list.map((i) => ({
  236. desc: i.time,
  237. title: i.context
  238. }))
  239. that.$set(that, `list`, list);
  240. that.$set(that, `no`, data.no);
  241. that.$set(that, `goods`, data.goods)
  242. } else {
  243. uni.showToast({
  244. title: '暂无物流信息!',
  245. icon: 'none'
  246. })
  247. }
  248. }
  249. }
  250. },
  251. // 选择选项卡
  252. tabsChange(e) {
  253. const that = this;
  254. that.$set(that.tabs, `active`, e.active)
  255. that.$set(that, `goods`, e?.goods)
  256. that.search()
  257. },
  258. }
  259. }
  260. </script>
  261. <style lang="scss">
  262. .main {
  263. display: flex;
  264. flex-direction: column;
  265. width: 100vw;
  266. height: 100vh;
  267. .second {
  268. padding: 2vw;
  269. .tabsList {
  270. .second_1 {
  271. margin: 0 0 2vw 0;
  272. .second_1_1 {
  273. padding: 1vw 0;
  274. }
  275. }
  276. }
  277. }
  278. }
  279. .uni-section .uni-section-header {
  280. padding: 1vw !important;
  281. }
  282. .uni-section .uni-section-content {
  283. padding: 0 !important;
  284. }
  285. </style>