doum
2 天以前 1dcd8399c853ef724133d4d1ad0d700db0f293e7
mini-program/pagesA/pages/write-off/write-off.vue
@@ -2,22 +2,122 @@
   <view class="box">
      <view class="title">输入自提码</view>
      <view class="input">
         <input type="number" placeholder="请输入6位自提码" />
         <input type="number" v-model="code" placeholder="请输入6位自提码" />
      </view>
      <view class="btn">确认</view>
      <view class="footer">
         <image src="/pagesA/images/ic_saoma@2x.png" mode="widthFix"></image>
      <view class="btn" v-if="!loading" @click="confirmDo">确认</view>
      <view class="btn1" v-if="loading" >正在查询</view>
      <view class="footer" @click="scanCodeDo">
         <image src="/pagesA/static/ic_saoma@2x.png" mode="widthFix"></image>
         <text>扫码核销</text>
      </view>
      <u-popup :show="show1" round="15" :safeAreaInsetBottom="false" mode="center">
         <view class="tc">
            <view class="tc-contemt">
               <view class="tc-contemt-title">订单查询结果</view>
               <view class="tc-contemt-nr">
                  订单【{{info.code}}】不满足核销条件!
               </view>
            </view>
            <view class="tc-btn">
               <view class="tc-btn-item" @click="show1=false ">确认</view>
            </view>
         </view>
      </u-popup>
   </view>
</template>
<script>
   import QRCode from 'qrcode';
   import { mapState } from 'vuex'
   export default {
      computed: {
         ...mapState(['navHeight', 'statusbarHeight','shopInfo', 'shopToken'])
      },
      data() {
         return {
            code:null,
            show1:false,
            loading:false,
            id:null,
            info:{}
         };
      },
      onShow() {
         this.loading =false
         this.show1 =false
         this.info={}
         this.code =''
         this.checkShopLogin()
      },
      onLoad(options) {
      },
      methods:{
         scanCodeDo(){
            this.code = ''
            var that =this
            uni.scanCode({
                success: function (res) {
                    console.log('条码类型:' + res.scanType);
                    console.log('条码内容:' + res.result);
                    // 处理扫描结果
                  that.code = res.result
                  that.confirmDo()
                },
                fail: function (err) {
                  uni.showToast({
                     title:'扫码失败',
                     icon:'error'
                  })
                }
            });
         },
         async confirmDo(){
            if(this.code ){
               this.getShopDetail()
            }
         },
         jumpWriteoffA(){
            if(this.info && this.info.orderId){
               uni.navigateTo({
                  url: '/pagesA/pages/write-off-a/write-off-a?id='+this.info.orderId
               })
            }
         },
         jumpBack(){
            uni.navigateBack({delta:1})
         },
          getShopDetail(){
            if(this.loading){
               return
            }
            this.loading =true
            var that =this
            that.$u.api.getOrderDetailByCode({exchangeCode:this.code,tokenType:1  })
            .then(res=>{
               console.log(res)
               if (res.code === 200) {
                  that.info = res.data
                  if(res.data.orderStatus == 1 && res.data.receiveType ==1){
                     that.jumpWriteoffA()
                  }else{
                     this.show1 = !this.show1
                     this.loading =false
                  }
               }
            }).catch(e=>{
               this.loading =false
            }).finally(e=>{
               // this.loading =false
            })
         },
         checkShopLogin(){
            var that =this
            if( this.shopInfo ==null || this.shopInfo.id==null ||  this.shopToken==null || this.shopToken==''){
               uni.navigateTo({
                  url: '/pages/login/login'
               })
            }
         },
      }
   }
</script>
@@ -55,6 +155,18 @@
            text-align: center;
         }
      }
      .btn1{
         width: 630rpx;
         height: 88rpx;
         line-height: 88rpx;
         text-align: center;
         background: #666666;
         border-radius: 44rpx;
         font-weight: 600;
         font-size: 32rpx;
         color: #FFFFFF;
         margin-top: 40rpx;
      }
      .btn {
         width: 630rpx;
         height: 88rpx;