123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293 |
- <template>
- <mobile-frame>
- <view class="main">
- <view class="second">
- <tabs :tabs="tabs" @tabsChange="tabsChange">
- <view class="tabsList">
- <view class="second_1">
- <view class="second_1_1">
- <text>订单状态:</text>
- <text>{{is_check}}</text>
- </view>
- <view class="second_1_1">
- <text>物流单号:</text>
- <text user-select="true">{{no}}</text>
- </view>
- <view class="second_1_1" v-if="type == 'order'">
- <text>包含商品:</text>
- <text v-for="(item,index) in goods" :key="index">{{item.goods_name}};</text>
- </view>
- </view>
- <view class="second_2">
- <uni-section title="物流记录" type="line" padding>
- <uni-steps :options="list" active-color="#007AFF" :active="active" direction="column" />
- </uni-section>
- </view>
- </view>
- </tabs>
- </view>
- </view>
- </view>
- </mobile-frame>
- </template>
- <script>
- import tabs from '../components/tabs/index.vue';
- export default {
- components: {
- tabs
- },
- data() {
- return {
- id: '',
- // 类型
- type: '',
- // 商品
- goods: [],
- // 标签页
- tabs: {
- active: '',
- menu: []
- },
- user: {},
- info: {},
- is_check: '',
- no: '',
- list: []
- };
- },
- onLoad: function(e) {
- const that = this;
- that.$set(that, `id`, e.id || '');
- that.$set(that, `type`, e.type || '');
- that.watchLogin()
- },
- methods: {
- watchLogin() {
- const that = this;
- uni.getStorage({
- key: 'token',
- success: function(res) {
- let user = that.$jwt(res.data);
- if (user) that.$set(that, `user`, user);
- that.searchInfo();
- }
- })
- },
- // 查商品详情
- async searchInfo() {
- const that = this;
- if (that.id) {
- let res;
- if (that.type == 'integral') {
- res = await that.$api(`/zrOrder/${that.id}`, `GET`, {}, `integral`)
- } else if (that.type == 'groupOrder') {
- res = await that.$api(`/groupOrder/${that.id}`, `GET`, {}, `group`)
- } else if (that.type == 'afterSale') {
- res = await that.$api(`/afterSale/${that.id}`, `GET`)
- that.$set(that.tabs, `active`, 'shop')
- that.$set(that.tabs, `menu`, [{
- title: '店铺物流',
- active: 'shop',
- }, {
- title: '用户物流',
- active: 'customer',
- }])
- } else if (that.type == 'groupAfterSale') {
- res = await that.$api(`/groupAfterSale/${that.id}`, `GET`, {}, 'group')
- that.$set(that.tabs, `active`, 'shop')
- that.$set(that.tabs, `menu`, [{
- title: '店铺物流',
- active: 'shop',
- }, {
- title: '用户物流',
- active: 'customer',
- }])
- } else {
- res = await that.$api(`/orderDetail/${that.id}`, 'GET')
- }
- if (res.errcode == '0') {
- if (that.type == 'order') {
- let res = await that.$api(`/orderDetail/sot`, `POST`, {
- id: that.id,
- });
- if (res.errcode == '0') {
- for (let [index, item] of res.data.entries()) {
- let num = index + 1
- item.title = `物流编号` + num;
- item.active = item.no
- }
- that.$set(that, `goods`, res?.data[0]?.goods)
- that.$set(that.tabs, `active`, res?.data[0]?.no)
- that.$set(that.tabs, `menu`, res.data)
- } else {
- uni.showToast({
- title: res.errmsg,
- icon: 'none'
- })
- }
- }
- that.$set(that, `info`, res.data);
- that.search();
- } else {
- uni.showToast({
- title: res.errmsg,
- icon: 'none'
- })
- }
- }
- },
- // 查物流信息
- async search() {
- const that = this;
- if (that.type == 'afterSale') {
- let arr = await that.$api(`/afterSale/getTransportInfo/${that.info.id}`, `GET`)
- if (arr.errcode == '0') {
- if (that.tabs.active == 'shop') {
- that.$set(that, `is_check`, arr.data?.shop.is_check);
- let list = arr.data?.shop.list.map((i) => ({
- desc: i.time,
- title: i.context
- }))
- that.$set(that, `list`, list);
- that.$set(that, `no`, arr.data?.shop.no);
- } else {
- that.$set(that, `is_check`, arr.data?.customer.is_check);
- let list = arr.data?.customer.list.map((i) => ({
- desc: i.time,
- title: i.context
- }))
- that.$set(that, `list`, list);
- that.$set(that, `no`, arr.data?.customer.no);
- }
- } else {
- uni.showToast({
- title: res.errmsg,
- icon: 'none'
- })
- }
- } else {
- if (that.type == 'integral') {
- let res = await that.$api(`/zrOrder/sot/${that.info._id}`, `GET`, {}, `integral`);
- if (res.errcode == '0') {
- that.$set(that, `is_check`, res.data.is_check);
- let list = res.data.list.map((i) => ({
- desc: i.time,
- title: i.context
- }))
- that.$set(that, `list`, list);
- that.$set(that, `no`, res.data.no);
- } else {
- uni.showToast({
- title: res.errmsg,
- icon: 'none'
- })
- }
- } else if (that.type == 'groupAfterSale') {
- let arr = await that.$api(`/orderOthers/afterSale/transport`, `POST`, {
- id: that.id
- }, `group`);
- if (arr.errcode == '0') {
- if (that.tabs.active == 'shop') {
- that.$set(that, `is_check`, arr.data?.shop.is_check);
- let list = arr.data?.shop.list.map((i) => ({
- desc: i.time,
- title: i.context
- }))
- that.$set(that, `list`, list);
- that.$set(that, `no`, arr.data?.shop.no);
- } else {
- that.$set(that, `is_check`, arr.data?.customer.is_check);
- let list = arr.data?.customer.list.map((i) => ({
- desc: i.time,
- title: i.context
- }))
- that.$set(that, `list`, list);
- that.$set(that, `no`, arr.data?.customer.no);
- }
- } else {
- uni.showToast({
- title: res.errmsg,
- icon: 'none'
- })
- }
- } else if (that.type == 'groupOrder') {
- let res = await that.$api(`/orderOthers/transport`, `POST`, {
- order: that.id
- }, `group`);
- if (res.errcode == '0') {
- that.$set(that, `is_check`, res?.data[0].is_check);
- let list = res?.data[0].list.map((i) => ({
- desc: i.time,
- title: i.context
- }))
- that.$set(that, `list`, list);
- that.$set(that, `no`, res?.data[0].no);
- } else {
- uni.showToast({
- title: res.errmsg,
- icon: 'none'
- })
- }
- } else {
- let data = that.tabs.menu.find((i) => i.no == that.tabs.active);
- if (data) {
- that.$set(that, `is_check`, data.is_check);
- let list = data.list.map((i) => ({
- desc: i.time,
- title: i.context
- }))
- that.$set(that, `list`, list);
- that.$set(that, `no`, data.no);
- that.$set(that, `goods`, data.goods)
- } else {
- uni.showToast({
- title: '暂无物流信息!',
- icon: 'none'
- })
- }
- }
- }
- },
- // 选择选项卡
- tabsChange(e) {
- const that = this;
- that.$set(that.tabs, `active`, e.active)
- that.$set(that, `goods`, e?.goods)
- that.search()
- },
- }
- }
- </script>
- <style lang="scss">
- .main {
- display: flex;
- flex-direction: column;
- width: 100vw;
- height: 100vh;
- .second {
- padding: 2vw;
- .tabsList {
- .second_1 {
- margin: 0 0 2vw 0;
- .second_1_1 {
- padding: 1vw 0;
- }
- }
- }
- }
- }
- .uni-section .uni-section-header {
- padding: 1vw !important;
- }
- .uni-section .uni-section-content {
- padding: 0 !important;
- }
- </style>
|