MrShi
3 天以前 743368e075a887c8fa4879ee039742b287b25d70
mini-program/pages/mine/mine.vue
@@ -88,12 +88,15 @@
            </view>
         </view>
      </view>
      <Login ref="login" />
   </view>
</template>
<script>
   import { mapState } from 'vuex'
   import Login from '@/components/login/login.vue'
   export default {
      components: { Login },
      computed: {
         ...mapState(['navHeight', 'statusbarHeight', 'openid', 'userInfo','recshopid','recuserid'])
      },
@@ -109,16 +112,20 @@
         if (uni.getStorageSync('backgroundImage')) {
            this.share = uni.getStorageSync('backgroundImage').centerInviteBg
         }
         this.ordersStatistics()
      },
      async onShow() {
         await this.$onLaunched;
         if (this.userInfo) {
            this.getMyInfo()
            this.ordersStatistics()
         }
      },
      methods: {
         jumpTo(type) {
            if (!this.userInfo) {
               this.$refs.login.open()
               return
            }
            if (type === 1) {
               uni.navigateTo({
                  url: '/pages/shopping-cart/shopping-cart'
@@ -161,20 +168,30 @@
         },
         // 授权手机号
         getphonenumber(e) {
            var that = this;
            if (e.detail.errMsg === 'getPhoneNumber:ok') {
               this.$u.api.wxPhone({
                  code: e.detail.code,
                  shopId:this.recshopid,
                  recId:this.recuserid,
                  openid: this.openid
               }).then(res => {
                  if (res.code === 200) {
                     this.$store.commit('setUserInfo', res.data.member)
                     this.$store.commit('setToken', res.data.token)
                      this.$store.commit('setRecShopId','')
                      this.$store.commit('setRecUserId','')
               uni.login({
                  provider: 'weixin',
                  success: async function (loginRes) {
                     let { code } = loginRes;
                     let res = await that.$u.api.wxLogin({ code })
                     if (res.code === 200) {
                        that.$u.api.wxPhone({
                           code: e.detail.code,
                           shopId:that.recshopid,
                           recId:that.recuserid,
                           openid: res.data.openid
                        }).then(res => {
                           if (res.code === 200) {
                              that.$store.commit('setUserInfo', res.data.member)
                              that.$store.commit('setToken', res.data.token)
                              that.$store.commit('setRecShopId','')
                              that.$store.commit('setRecUserId','')
                           }
                        })
                     }
                  }
               })
               });
            }
         },
         // 获取收藏等数量
@@ -197,6 +214,10 @@
         },
         // 跳转订单列表
         jumpOrder(status) {
            if (!this.userInfo) {
               this.$refs.login.open()
               return
            }
            uni.navigateTo({
               url: '/pagesA/pages/order/order?userType=0&status=' + status
            })