Blame view

apps/pages/order/deliver.vue 9.14 KB
yyq authored
1
<template>
yyq authored
2
  <LayoutApp class="order-deliver-page" title="发货" :show-back="true">
yyq authored
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
    <div class="main-content">
      <div class="identify-center-address">
        <div class="left-icon">
          <i class="iconfont iconaddress"></i>
        </div>
        <div class="address-info">
          <div class="consignee">
            <span>{{stateCenterAddress.address_name}}</span>
            <span class="tag">有货鉴定中心</span>
          </div>
          <p class="location">{{stateCenterAddress.address}}</p>
          <p>{{stateCenterAddress.mobile}}</p>
        </div>
      </div>
      <div class="deliver-express">
        <div class="left-icon">
          <div class="express-logo"></div>
        </div>
        <div class="express-info">
yyq authored
22
          <div class="express-name">顺丰快运</div>
yyq authored
23
          <CubeInput class="express-input" v-model="expressCode" placeholder="请填写顺丰运单号"></CubeInput>
yyq authored
24
          <span v-if="canScan" class="iconfont iconscan scan-btn" @click="scanCode"></span>
yyq authored
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
        </div>
      </div>
      <div v-if="stateCenterAddress.deliverDesc" class="deliver-tip">
        <span class="iconfont iconwarn"></span>
        <p>{{stateCenterAddress.deliverDesc}}</p>
      </div>
      <div class="submit-warp">
        <div class="contract-check">
          <i class="iconfont" :class="readContract ? 'iconcheck_full checked' : 'iconcheck_default'" @click="changeReadContract"></i>
          <span>我已阅读并同意</span>
          <a href="//activity.yoho.cn/feature/4049.html?share_id=6729&title=UFO卖家商品质检标准">《UFO卖家商品质检标准》</a>
        </div>
        <p v-if="stateCenterAddress.warnTips" class="warn-tip">{{stateCenterAddress.warnTips}}</p>
        <CubeButton class="deliver-btn" :disabled="deliverDisable" @click="submitDeliver">发货</CubeButton>
      </div>
    </div>
  </LayoutApp>
</template>

<script>
import { get } from 'lodash';
import { Button, Input } from 'cube-ui';
import { createNamespacedHelpers } from 'vuex';

const { mapState, mapActions } = createNamespacedHelpers('order/orderDeliver');

export default {
  name: 'OrderDeliver',
  data() {
    return {
yyq authored
55
      canScan: false,
yyq authored
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
      centerAddress: {},
      expressCode: '',
      readContract: false
    };
  },
  created() {
    let { skup, code } = this.$route.params || {};

    this.orderCode = code;
    if (process.env.VUE_ENV !== 'server') {
      this.fetchAppraiseAddress({
        skup,
        orderCode: code
      });
    }
  },
  computed: {
    ...mapState(['appraiseAddress']),
    stateCenterAddress() {
      if (!this.centerAddress.address) {
        this.centerAddress = get(this.appraiseAddress, this.orderCode) || {};
      }

      return this.centerAddress;
    },
    deliverDisable() {
yyq authored
82
      return !(this.expressCode && this.readContract);
yyq authored
83 84 85
    }
  },
  mounted() {
yyq authored
86 87 88 89
    if (this.$yoho.isAliApp) {
      this.canScan = true;
    }
yyq authored
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
    this.fetchAppraiseAddressChangeNotice({orderCode: this.orderCode}).then(res => {
      let isChanged = get(res, 'data.isChanged');
      let isForceShow = get(res, 'data.isForceShow');

      if (!isChanged && !isForceShow) {
        return;
      }

      let { title = '', tips, alert_address_name, alert_address, alert_mobile } = res.data || {};
      let info = [
        alert_address_name || '',
        alert_address || '',
        alert_mobile || ''
      ];

      if (isChanged && tips) {
        info.unshift(tips);
      }

      this.$createDialog({
        type: 'alert',
        confirmBtn: {
          text: '我知道了'
        },
        onConfirm() {
          // Todo report()
          console.log('Todo Report', res.data);
        }
      }, (createElement) => {
        return [
          createElement('div', {
            class: {
              'dg-notice-content': true
            },
            slot: 'content'
          }, [
            createElement('div', {
              class: {
                'dg-notice-content-title': true
              }
            }, isChanged ? 'UFO仓库调整公告' : title),
            ...info.map(val => {
              return createElement('p', {
                class: {
                  'dg-notice-content-info': true
                },
              }, val);
            })
          ])
        ];
      }).show();
    });
  },
  methods: {
    ...mapActions(['fetchAppraiseAddress', 'fetchAppraiseAddressChangeNotice', 'deliverOrderToDepot']),
    toast(msg, time = 1500) {
      this.$createToast && this.$createToast({
        txt: msg,
        type: 'txt',
        time
      }).show();
    },
yyq authored
152 153 154 155 156 157 158 159 160
    scanCode() {
      if (window && window.WindVane) {
        window.WindVane.call('Scancode', 'scan', {}, e => {
          if (e && e.code) {
            this.expressCode = e.code;
          }
        });
      }
    },
yyq authored
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
    changeReadContract() {
      this.readContract = !this.readContract;
    },
    submitDeliver() {
      if (/^[a-zA-Z0-9]+$/.test(this.expressCode)) {
        if (this.loading) {
          return;
        }

        this.loading = true;

        setTimeout(() => {
          this.loading = false;
        }, 2000);

        this.deliverOrderToDepot({
          orderCode: this.orderCode,
          wayBillCode: this.expressCode,
          depotNum: this.stateCenterAddress.id
        }).then(res => {
          if (res.code === 200) {
            this.$router.go(-1);
            // Todo report()
          } else {
            this.toast(res.message || '网络异常,请稍后重试');
          }
        });
      } else {
        this.toast('请输入正确的快递单号');
      }
    }
  },
  components: {
    CubeButton: Button,
    CubeInput: Input
  }
};
</script>

<style lang="scss">
.dg-notice-content {
  padding: 10px 44px 40px;
  font-size: 28px;
  line-height: 42px;
  color: #444;
  margin-bottom: -32px;
  border-bottom: 1px solid #f5f5f5;

  .dg-notice-content-title {
    font-size: 32px;
    font-weight: 500;
    text-align: center;
    padding-bottom: 20px;
    color: #000;
  }
}

</style>

<style lang="scss" scoped>
.order-deliver-page {
  .main-content {
yyq authored
223
    padding: 20px 40px 0;
yyq authored
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
  }

  .left-icon {
    width: 88px;
    flex-shrink: 0;
  }

  .identify-center-address {
    padding: 40px 0;
    display: flex;
    align-items: center;
    font-size: 28px;
    border-bottom: 1px solid #eee;

    .iconfont {
      font-size: 48px;
    }

    .consignee {
      font-size: 32px;
      display: flex;
      align-items: center;

      > * {
        line-height: 44px;
        font-weight: 800;
        display: inline-block;
        vertical-align: top;
      }

      .tag {
        font-size: 24px;
yyq authored
256
        height: 48px;
yyq authored
257 258 259 260 261 262
        line-height: 48px;
        font-weight: 300;
        padding: 0 14px;
        margin-left: 6px;
        color: #002B47;
        border: 1px solid #ccc;
yyq authored
263
        border-radius: 10px;
yyq authored
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297
        box-sizing: border-box;
        transform: scale(0.8);
      }
    }

    .location {
      font-size: 24px;
      line-height: 1.4;
      color: #999;
      margin: 6px 0 12px;
    }
  }

  .deliver-express {
    display: flex;
    padding: 36px 0;
    border-bottom: 1px solid #eee;
    align-items: center;

    .express-logo {
      width: 48px;
      height: 48px;
      background: url("~statics/image/order/sf-logo.png");
      background-size: 100% 100%;
    }

    .express-info {
      font-size: 32px;
      line-height: 44px;
      display: flex;
      align-items: center;
      flex-grow: 1;
    }
yyq authored
298 299 300 301 302
    .express-name {
      white-space: nowrap;
      flex-shrink: 0;
    }
yyq authored
303 304
    .express-input {
      flex-grow: 1;
yyq authored
305
      margin-left: 20px;
yyq authored
306 307 308 309 310 311 312 313 314 315

      &:after {
        border: 0;
      }

      /deep/ .cube-input-field {
        text-align: right;
        padding: 0;
      }
    }
yyq authored
316 317 318 319 320 321 322 323

    .scan-btn {
      font-size: 40px;
      color: #444;
      font-weight: 500;
      margin-left: 10px;

    }
yyq authored
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353
  }

  .deliver-tip {
    color: #ccc;
    display: flex;
    align-items: flex-start;
    padding-top: 16px;

    .iconfont {
      font-size: 32px;
      margin-right: 10px;
      margin-top: -6px;
    }

    p {
      font-size: 24px;
      line-height: 1.4;
      font-weight: 300;
      color: #bbb;
      white-space: pre-wrap;
      word-wrap: break-word;
    }
  }

  .submit-warp {
    width: 100%;
    position: absolute;
    left: 0;
    bottom: 0;
    padding: 0 38px 40px;
yyq authored
354
    background-color: #fff;
yyq authored
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398
  }

  .contract-check {
    font-size: 24px;
    line-height: 40px;
    color: #999;
    display: flex;
    align-items: center;

    .iconfont {
      margin-right: 16px;
      font-size: 30px;
      position: relative;

      &:after {
        content: "";
        width: 200%;
        height: 150%;
        position: absolute;
        top: -25%;
        left: -50%;
      }
    }

    .checked {
      color: #022c46;
    }

    a {
      color: #65ab85;
      margin-left: 20px;
      text-decoration: underline;
    }
  }

  .warn-tip {
    font-size: 24px;
    line-height: 1.3;
    color: red;
    padding: 6px 0;
    letter-spacing: 0;
  }

  .deliver-btn {
yyq authored
399 400 401 402
    height: 88px;
    padding: 0;
    border-radius: 44px;
    background: #022b47;
yyq authored
403
    margin-top: 34px;
yyq authored
404 405 406 407 408 409 410
    display: flex;
    align-items: center;
    justify-content: center;

    &:after {
      display: none;
    }
yyq authored
411 412 413 414 415 416 417

    &.cube-btn_disabled {
      background: #ccc;
    }
  }
}
</style>