#
whycq
2024-12-05 51ff61a68be3db46dbaef2677986b396736b1198
pages/common/modeSwitch.vue
@@ -5,8 +5,7 @@
      </view>
      
      <view class="buttom">
         <button type="primary" size="mini">模式切换</button>
         <button type="primary" size="mini" @click="change()">模式切换</button>
      </view>
   </view>
</template>
@@ -15,11 +14,65 @@
   export default {
      data() {
         return {
            modeText: '默认'
            baseUrl: '',
            token: '',
            modeText: '默认',
            sign: true,
         }
      },
      onShow() {
         this.baseUrl = uni.getStorageSync('baseUrl');
         this.token = uni.getStorageSync('token');
         this.getInfo()
      },
      methods: {
         getInfo() {
            let _this = this
            uni.request({
               url: `${_this.baseUrl}/mobile/search/sign/auth/v2`,
               data: {sign:false},
               header: {
                  'token': uni.getStorageSync('token'),
                  'content-type': 'application/x-www-form-urlencoded'
               },
               method: 'POST',
               success(res) {
                  console.log(res);
                  res = res.data
                  if (res.code === 200) {
                     if (res.data == 0) {
                        _this.modeText = "默认"
                     } else {
                        _this.modeText = "退库"
                     }
                  }
               }
            })
         },
         change() {
            let _this = this
            uni.request({
               url: `${_this.baseUrl}/mobile/search/sign/auth/v2`,
               data: {sign:true},
               header: {
                  'token': uni.getStorageSync('token'),
                  'content-type': 'application/x-www-form-urlencoded'
               },
               method: 'POST',
               success(res) {
                  res = res.data
                  console.log(res);
                  if (res.code === 200) {
                     if (res.data == 0) {
                        _this.modeText = "默认"
                     } else {
                        _this.modeText = "退库"
                     }
                  }
               }
            })
         }
      }
   }
</script>