site.vue 19.5 KB
Newer Older
lanbaoming's avatar
lanbaoming committed
1
<template>
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
  <view>
    <view class="site">
      <view class="header-toper">
        <!-- <view class="start-bar"></view> -->
        <view class="header-toper-title">
          <image src="../../static/img/back.png" mode="" @click="goPage('../index/index')"></image>
          <text>{{ $lang.lang.site.set }}</text>
        </view>
      </view>
      <!-- <view class="start-bar"></view> -->
      <view class="items mt200">
        <view class="items-v">
          <image src=".../../static/img/site_vip.png" mode=""></image>
          <view class="items-v-it">
            <text>{{ $lang.lang.site.vip }}</text>
17
            <view class="text">{{ userScoreLevelInfo.levelName }}</view>
18 19 20 21 22 23 24 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 55 56 57 58
          </view>
        </view>
        <view class="items-v" @click="$request.goPage('../auth/auth')">
          <image src=".../../static/img/site_auth.png" mode=""></image>
          <view class="items-v-it">
            <text>{{ $lang.lang.site.auth }}</text>
            <view
              :class="
                idStatus == 2
                  ? 'items-v-it-rt color36'
                  : idStatus == 1
                  ? 'items-v-it-rt rte6'
                  : 'items-v-it-rt'
              "
              >{{ noticeId }}</view
            >
          </view>
        </view>
        <view class="items-v">
          <image src=".../../static/img/site_company.png" mode=""></image>
          <view class="items-v-it noborder">
            <text>{{ $lang.lang.site.comAuth }}</text>
            <view
              :class="
                companyStatus == 2
                  ? 'items-v-it-rt color36'
                  : companyStatus == 1
                  ? 'items-v-it-rt rte6'
                  : 'items-v-it-rt'
              "
              >{{ companyNotice }}</view
            >
          </view>
        </view>
      </view>

      <view class="items">
        <view class="items-v">
          <image src=".../../static/img/site_tel.png" mode=""></image>
          <view class="items-v-it">
            <text v-if="userInfo"
honghy's avatar
honghy committed
59
              >{{ $lang.lang.site.bindTel }}:<br>
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
              {{ userInfo.areaCode ? $request.checkAddIcon(userInfo.areaCode) : ''
              }}{{
                userInfo.mobile
                  ? userInfo.mobile.substr(0, 3) + '****' + userInfo.mobile.substr(8, 3)
                  : $lang.lang.site.unbind
              }}</text
            >
            <view class="items-v-it-rt rte036" @click="changMobile">{{
              $lang.lang.site.changeBind
            }}</view>
          </view>
        </view>
        <view class="items-v">
          <image src=".../../static/img/mail.png" mode=""></image>
          <view class="items-v-it">
honghy's avatar
honghy committed
75 76
            <text v-if="userInfo"
              >{{ $lang.lang.site.bindEmail }}:<br><span class="email">{{
77 78 79 80 81 82 83 84 85 86 87 88 89 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
                userInfo.email || $lang.lang.site.unbind
              }}</span></text
            >
            <view class="items-v-it-rt rte036" @click="changMail">{{
              userInfo.email ? $lang.lang.site.changeBind : $lang.lang.site.tobind
            }}</view>
          </view>
        </view>
        <view class="items-v" @click="toEditPsd">
          <image src=".../../static/img/site_pass.png" mode=""></image>
          <view class="items-v-it">
            <text>{{ $lang.lang.site.editPsd }}</text>
            <image class="rgt" src="../../static/img/rgt.png" mode=""></image>
          </view>
        </view>
        <view class="items-v" @click="$request.goPage('../telcode/telcode')">
          <image src=".../../static/img/site_pass.png" mode=""></image>
          <view class="items-v-it noborder">
            <text>{{ $lang.lang.site.controlPsd }}</text>
            <image class="rgt" src="../../static/img/rgt.png" mode=""></image>
          </view>
        </view>
      </view>

      <view class="items">
        <view class="items-v" @click="toMyInfo">
          <image src=".../../static/img/site_person.png" mode=""></image>
          <view class="items-v-it">
            <text>{{ $lang.lang.site.info }}</text>
            <image class="rgt" src="../../static/img/rgt.png" mode=""></image>
          </view>
        </view>
        <view class="items-v" @click="toCompanyInfo">
          <image src=".../../static/img/site_company.png" mode=""></image>
          <view class="items-v-it">
            <text>{{ $lang.lang.site.companyInfo }}</text>
            <image class="rgt" src="../../static/img/rgt.png" mode=""></image>
          </view>
        </view>
116
        <view class="items-v" @click="toAddress">
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
          <image src=".../../static/img/site_address.png" mode=""></image>
          <view class="items-v-it noborder">
            <text>{{ $lang.lang.site.address }}</text>
            <image class="rgt" src="../../static/img/rgt.png" mode=""></image>
          </view>
        </view>
      </view>

      <view class="items">
        <view class="items-v" @click="$request.goPage('../help/help')">
          <image src=".../../static/img/site_help.png" mode=""></image>
          <view class="items-v-it">
            <text>{{ $lang.lang.site.help }}</text>
            <image class="rgt" src="../../static/img/rgt.png" mode=""></image>
          </view>
        </view>
Smile's avatar
Smile committed
133 134 135 136 137 138 139 140
        <!--屏蔽汇率查询入口-->
<!--        <view class="items-v" @click="$request.goPage('../ecash/ecash')">-->
<!--          <image src=".../../static/img/site_person.png" mode=""></image>-->
<!--          <view class="items-v-it noborder">-->
<!--            <text>{{ $lang.lang.site.search }}</text>-->
<!--            <image class="rgt" src="../../static/img/rgt.png" mode=""></image>-->
<!--          </view>-->
<!--        </view>-->
141 142
      </view>
      <!-- 			<view class="es-btn" @click="getAdData(1)">
lanbaoming's avatar
lanbaoming committed
143 144 145 146 147
				<text>V{{version}}<text class="redtext" v-if="adData">{{$lang.lang.notices.newVersions}}</text></text>
			</view>
			<view class="es-btn">
				<text>V{{version}}</text>
			</view> -->
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
      <view class="items">
        <!-- #ifdef APP-PLUS -->
        <view class="items-v" @click="getAdData(1)">
          <image src=".../../static/img/site_person.png" mode=""></image>
          <view class="items-v-it">
            <text
              >V{{ version
              }}<text class="redtext" v-if="adData">{{
                $lang.lang.notices.newVersions
              }}</text></text
            >
            <!-- <image class="rgt" src="../../static/img/rgt.png" mode=""></image> -->
          </view>
        </view>
        <!-- #endif -->
Smile's avatar
Smile committed
163
        <view class="items-v">
164 165 166
          <image src=".../../static/img/earth.png" mode=""></image>
          <view class="items-v-it">
            <text>{{ $lang.lang.site.change }}</text>
Smile's avatar
Smile committed
167 168 169
            <picker class="languageCode" :range="languageName" :value="index" @change="changeLang">
              <view class="uni-input">{{languageName[index]}}</view>
            </picker>
170 171 172 173 174 175 176 177 178 179
          </view>
        </view>
      </view>
    </view>
    <view class="footer">
      <view @click="loginOut">{{ $lang.lang.site.exit }}</view>
    </view>
    <view class="footer2">
      <view @click="loginOff" class="logoff">{{ $lang.lang.site.logOff }}</view>
    </view>
lanbaoming's avatar
lanbaoming committed
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 223 224 225 226 227 228 229 230 231 232 233 234 235
    <uni-popup ref="adpopup" type="center" :mask-click="false">
      <view class="ad-conten">
        <image
          v-if="!forceUpdate"
          @click="closeAd"
          class="ad-bg"
          src="../../static/img/index_close.png"
        ></image>
        <view class="ad-title">V{{ appVersion }}{{ $lang.lang.notices.newVersion }}</view>
        <view class="ad-info">
          <rich-text :nodes="adData"></rich-text>
        </view>
        <view class="ad-btns">
          <view class="ad-btn" @click="toupdate">
            <view>{{ $lang.lang.notices.update }}</view>
          </view>
          <view v-if="!forceUpdate" class="ad-btn" @click="closeAd">
            <view>{{ $lang.lang.notices.close }}</view>
          </view>
        </view>
        <view class="progress" v-if="showdownLine">
          <progress :percent="downloadNum" show-info stroke-width="3" />
        </view>
      </view>
    </uni-popup>
    <uni-popup ref="newpass" type="center">
      <view class="newpass_content">
        <view class="newpss_title">{{ $lang.lang.site.startPsd }}</view>
        <view class="login-item">
          <view class="login-vp login-v">
            <input
              class="vp-input"
              v-model="password"
              type="password"
              maxlength="32"
              :placeholder="$lang.lang.notices.numPsd"
            />
          </view>
          <view class="login-vp login-v">
            <input
              class="vp-input"
              v-model="password2"
              type="password"
              maxlength="32"
              :placeholder="$lang.lang.notices.password"
            />
          </view>
        </view>
        <view class="login-btns">
          <view class="" @click="setpsd">{{ $lang.lang.site.confirm }}</view>
          <view class="" @click="$refs.newpass.close()">{{ $lang.lang.site.cancel }}</view>
        </view>
      </view>
    </uni-popup>
  </view>
lanbaoming's avatar
lanbaoming committed
236 237 238
</template>

<script>
239
import storage from '../../utils/storage'
240 241 242 243
export default {
  data() {
    return {
      userInfo: {},
Smile's avatar
Smile committed
244 245 246 247 248 249 250 251
      index: 0,
      languageName:['Chinese', 'English','French'],
      language:'zh',
      languages: [
        { value: 'zh', text: "Chinese" },
        { value: 'en', text: "English" },
        { value: 'fr', text: "French" },
      ],
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
      noticeId: this.$lang.lang.site.unauth,
      statusData: [],
      companyNotice: this.$lang.lang.site.unauth,
      idStatus: 0,
      companyStatus: 0,
      password: '',
      password2: '',
      isHavePassword: false,
      locale: this.$request.getLocale(),
      version: '1.0.2',
      appUrl: '',
      adData: '',
      versionCode: 0,
      appVersion: '',
      forceUpdate: 0,
      showdownLine: false,
      downloadNum: 0, //下载百分比
269 270 271
      totalSize: 0, //下载总量
      // 用户等级信息
      userScoreLevelInfo: {}
272 273 274 275 276
    }
  },
  onLoad() {
    this.getVersion()
    this.getStatusData()
277
    this.showLangView()
278 279 280 281 282 283 284 285 286 287 288 289
    //#ifdef APP-PLUS
    this.getAdData(2)
    //#endif
  },
  onShow() {
    this.getUserInfo()
    setTimeout(() => {
      // this.getCompany()
      this.getIdcard()
    }, 500)
  },
  methods: {
290 291 292 293
    showLangView() {
      const lang=uni.getStorageSync('locale')||'zh';
      this.index=this.languages.findIndex(item => item.value === lang);
    },
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 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 354 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 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421
    toupdate() {
      let that = this
      if (that.showdownLine) return
      // #ifdef APP-PLUS

      let platform = uni.getSystemInfoSync().platform.toLocaleLowerCase()
      if (platform == 'ios') {
        plus.runtime.openURL('https://apps.apple.com/us/app/e-c-logistics/id6466407990')
      } else {
        // uni.showLoading({
        // 	title: this.$lang.lang.notices.startDown,
        // })
        that.showdownLine = true
        uni.showLoading({
          title: this.$lang.lang.notices.startDown
        })
        var dtask = plus.downloader.createDownload(
          that.appUrl,
          {
            timeout: 60,
            retry: 1,
            retryInterval: 3
          },
          (d, status) => {
            if (status == 200) {
              uni.hideLoading()
              that.closeVe()
              that.showdownLine = false
              console.log('下载成功安装: ' + d.filename)
              plus.runtime.install(
                d.filename,
                {},
                () => {},
                function (error) {
                  uni.showToast({
                    title: that.$lang.lang.notices.failDown,
                    duration: 1500,
                    icon: 'none'
                  })
                }
              )
            } else {
              that.showdownLine = false
              that.closeVe()
              plus.nativeUI.alert(that.$lang.lang.notices.failDown)
            }
          }
        )

        // uni.navigateTo({
        // 	url:'../updateView/updateView?url='+this.appUrl
        // })

        try {
          dtask.start()
          // 下载进度
          dtask.addEventListener('statechanged', function (download, status) {
            if (that.downloadNum == 100) {
              uni.hideLoading()
            }
            switch (download.state) {
              case 1:
                showLoading.setTitle('正在下载')
                break
              case 2:
                break
              case 3: //进度条百分比 totalSize为总量,baifen为当前下载的百分比
                if (that.totalSize == 0) {
                  that.totalSize = parseInt(download.totalSize)
                }
                if (
                  parseInt((download.downloadedSize / that.totalSize) * 100) != that.downloadNum
                ) {
                  that.downloadNum = parseInt((download.downloadedSize / that.totalSize) * 100)
                }
                break
              case 4:
                // mui.toast("下载完成");
                uni.hideLoading()
                break
            }
          })
        } catch (err) {
          uni.hideLoading()
          that.showdownLine = false
          that.closeVe()
          uni.showToast({
            title: that.$lang.lang.notices.failDown,
            duration: 1500,
            icon: 'none'
          })
        }
      }
      // #endif
    },
    openAd() {
      this.$refs.adpopup.open()
    },
    closeAd() {
      this.$refs.adpopup.close()
    },
    getAdData(n) {
      let that = this
      var addType = uni.getSystemInfoSync().platform == 'ios' ? 'userIos' : 'userAndroid'
      that.$request
        .get('/app-api/system/version/latestVersion', {
          appType: addType,
          versionCode: that.versionCode
        })
        .then((res) => {
          if (res.code == 0 && res.data) {
            that.adData = res.data.desp
            that.appUrl = res.data.appUrl
            that.appVersion = res.data.appVersion
            that.forceUpdate = res.data.forceUpdate
            if (n == 1) {
              that.openAd()
            }
          } else {
            if (n == 1) {
              uni.showToast({
                title: that.$lang.lang.notices.nowNews,
                icon: 'none'
              })
            }
          }
        })
    },
Smile's avatar
Smile committed
422 423 424
    changeLang(e) {
      this.index = e.detail.value
      const data = this.languages[e.detail.value].value;
425 426
      this.locale = data
      uni.setStorageSync('locale', data)
427
      uni.setLocale(data);
428
      this.$lang.setLang(data)
Smile's avatar
Smile committed
429 430 431
      // #ifdef H5
      window.location.reload();
      // #endif
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466
      this.getIdcard()
      ;(this.companyNotice = this.$lang.lang.site.unauth),
        uni.showToast({
          title: data == 'zh' ? '切换成功' : 'Handover successful'
        })
    },
    goPage() {
      uni.reLaunch({
        url: '../index/index',
        success() {}
      })
    },
    toEditPsd() {
      if (!this.isHavePassword) {
        this.$refs.newpass.open()
      } else {
        uni.navigateTo({
          url: '../editPsd/editPsd'
        })
      }
    },
    changMobile() {
      if (!this.isHavePassword) {
        this.$refs.newpass.open()
      } else {
        uni.navigateTo({
          url: '../changeTel/changeTel'
        })
      }
    },
    getUserInfo() {
      this.$request.get('/app-api/member/user/get').then((res) => {
        if (res.code == 0 && res.data) {
          this.userInfo = res.data
          this.isHavePassword = this.userInfo.isHavePassword
467
          this.userScoreLevelInfo = res.data.userScoreLevelInfo
468 469 470 471 472
        }
      })
    },
    loginOut() {
      uni.removeStorageSync('Authorization')
473
      storage.clean()
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496
      uni.navigateTo({
        url: '../login/login'
      })
    },
    getIdcard() {
      this.$request.get('/app-api/member/user/get-auth-idcard-info').then((res) => {
        if (res.code == 0 && res.data) {
          this.noticeId = this.getNoticeName(res.data.status)
          this.idStatus = res.data.status
        }
      })
    },
    getCompany() {
      this.$request.get('/app-api/member/user/get-auth-enterprise-info').then((res) => {
        if (res.code == 0 && res.data) {
          this.companyNotice = this.getNoticeName(res.data.status)
          this.companyStatus = res.data.status
        }
      })
    },
    getNoticeName(status) {
      var arr = this.statusData.find((item) => item.value == status)
      if (arr) {
Smile's avatar
Smile committed
497
        return arr[this.$lang.label]
498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535
      } else {
        return ''
      }
    },
    getVersion() {
      this.version = uni.getStorageSync('appversion')
      this.versionCode = uni.getStorageSync('versionCode')
    },
    getStatusData() {
      this.$request.getConfig('audit_status').then((res) => {
        if (res.code == 0 && res.data && res.data.list.length > 0) {
          this.statusData = res.data.list
        }
      })
    },
    toMyInfo() {
      uni.navigateTo({
        url: '../my_info/my_info'
      })
    },
    toCompanyInfo() {
      uni.navigateTo({
        url: '../company_info/company_info'
      })
    },
    changMail() {
      if (!this.isHavePassword) {
        this.$refs.newpass.open()
      } else {
        uni.navigateTo({
          url: '../edit_mail/edit_mail'
        })
      }
    },
    setpsd() {
      let params = {
        password: this.password2
      }
lanbaoming's avatar
lanbaoming committed
536

537 538 539
      if (this.password == '') {
        return uni.showToast({
          title: this.$lang.lang.notices.password,
honghy's avatar
honghy committed
540
          icon: 'none'
541 542 543 544 545 546
        })
      } else {
        var reg1 = new RegExp('^(?=.*[0-9])(?=.*[a-zA-Z])(.{6,32})$')
        if (!reg1.test(this.password)) {
          return uni.showToast({
            title: this.$lang.lang.notices.numPsd,
honghy's avatar
honghy committed
547
            icon: 'none'
548 549 550 551 552 553
          })
        }
      }
      if (this.password2 == '') {
        return uni.showToast({
          title: this.$lang.lang.notices.nextPsd,
honghy's avatar
honghy committed
554
          icon: 'none'
555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582
        })
      }
      if (this.password != this.password2) {
        return uni.showToast({
          title: this.$lang.lang.notices.different,
          icon: 'none'
        })
      }
      let that = this
      that.$request.post('/app-api/member/update-password', params).then((res) => {
        if (res.code == 0) {
          that.getUserInfo()
          that.$refs.newpass.close()
          uni.showToast({
            title: this.$lang.lang.notices.edited,
            icon: 'none'
          })
        } else {
          uni.showToast({
            title: res.msg,
            icon: 'none'
          })
        }
      })
    },
    loginOff() {
      let that = this
      uni.showModal({
honghy's avatar
honghy committed
583
        title: that.$lang.lang.create.tips,
584 585 586 587 588
        content: that.$lang.lang.site.logNotice,
        success: function (res) {
          if (res.confirm) {
            that.$request.deleted('/app-api/member/member/cancellation').then((res) => {
              if (res.code == 0 && res.data) {
589
                storage.clean()
590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614
                uni.showToast({
                  title: that.$lang.lang.site.offSuccess,
                  icon: 'none'
                })
                uni.setStorageSync('Authorization', '')
                setTimeout(() => {
                  uni.reLaunch({
                    url: '../login/login'
                  })
                  // uni.reLaunch({
                  // 	url: '../login/login'
                  // })
                }, 2000)
              } else {
                uni.showToast({
                  title: res.msg,
                  icon: 'none'
                })
              }
            })
          } else if (res.cancel) {
            console.log('用户点击取消')
          }
        }
      })
615 616 617 618 619 620
    },
    // 跳转地址信息
    toAddress() {
      uni.navigateTo({
        url: '../address/address'
      })
621 622 623
    }
  }
}
lanbaoming's avatar
lanbaoming committed
624 625 626
</script>

<style>
627
@import url(../../static/css/site.css);
lanbaoming's avatar
lanbaoming committed
628
</style>