index.vue 18.8 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 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
  <view class="main">
    <view class="hd-v">
      <view class="start-bar"></view>
      <view class="tabs">
        <view class="">{{ $lang.lang.index.index }}</view>
        <view class="igs">
          <view class="index_msg" @click="$request.goPage('../msg/msg')">
            <image src="../../static/img/notice.png" mode=""></image>
            <view v-if="msgHave" class="msg_dian"></view>
          </view>
          <view class="" @click="goPage('../site/site')">
            <image src="../../static/img/site.png" mode=""></image>
          </view>
        </view>
      </view>
      <view class="banner">
        <swiper class="swiper" circular indicator-dots autoplay interval="2000" duration="500">
          <swiper-item v-for="(item, index) in banner" @click="toBanner(item.id)" :key="index">
            <image :src="item.bannerUrlApp" mode=""></image>
          </swiper-item>
        </swiper>
      </view>
    </view>
    <view class="nvs">
      <!--			<view class="index_msg" v-for="(item, index) in nvs" @click="toPage(item.url)" :key="index">-->
      <view
        class="index_msg"
        v-for="(item, index) in nvs"
        @click="toPage(item.url, item.isHttp)"
        :key="index"
      >
        <image :src="item.icon" mode=""></image>
        <view v-if="item.num > 0" class="order_dian">{{ item.num }}</view>
        <text>{{ item.name }}</text>
      </view>
    </view>
    <!-- 搜索 -->
    <!--		<view class="order-tabs">
lanbaoming's avatar
lanbaoming committed
40 41 42 43 44 45 46 47
			<view class="order-tabs-v2">
				<view class="order-tabs-v2s">
					<image class="search" src="../../static/img/search.png" mode=""></image>
					<input type="text" v-model="searchKey" autocomplete="off" :placeholder="$lang.lang.notices.moreKey" placeholder-style="color: #666666">
					<view class="" @click="toMyOrder">{{$lang.lang.order.search}}</view>
				</view>
			</view>
		</view>-->
48 49 50 51 52 53
    <view class="mssgv">
      <view class="mssgv-v" @click="$request.goPage('../notice/notice')">
        <view class="mssgv-v-1">
          <text>{{ $lang.lang.index.system }}</text>
          <text>{{ $lang.lang.index.notice }}</text>
        </view>
lanbaoming's avatar
lanbaoming committed
54

55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
        <view class="notice">
          <swiper
            class="swiper-nav"
            :circular="true"
            :vertical="true"
            :autoplay="true"
            :interval="4000"
            :duration="1000"
            style="height: 70px"
          >
            <swiper-item
              style="display: table"
              @touchmove.stop="stopTouchMove"
              v-for="(item, index) in noticeData"
              :key="index"
            >
              <view class="mssgv-v-2">
honghy's avatar
honghy committed
72
                <view class="">{{ $lang.locale == 'zh' ? item.title : $lang.locale == 'en'?item.titleEn:item.titleFr }}</view>
73 74 75 76 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
                <view class="">
                  <image src="../../static/img/time.png" mode=""></image>
                  <text>{{ getDate(item.createTime) }}</text>
                </view>
              </view>
              <image class="rgt" src="../../static/img/rgt.png" mode="widthFix"></image>
            </swiper-item>
          </swiper>
        </view>
      </view>
    </view>
    <view class="actions">
      <view class="title">
        <image src="../../static/img/dongtai.png" mode=""></image>
        <text>{{ $lang.lang.index.dynamic }}</text>
      </view>
      <view class="act-list">
        <view v-if="orderData.length == 0" class="noData">
          <image src="../../static/img/empty.png" mode="widthFix"></image>
          <text>{{ $lang.lang.notices.noData }}~</text>
        </view>
        <template v-else>
          <view
            class="item"
            v-for="(item, index) in orderData"
            :key="item.orderId"
            @click="toOrderInfo(item.orderId)"
          >
            <view class="item-til">
              <image src="../../static/img/sn.png" mode=""></image>
honghy's avatar
honghy committed
103 104
              <view class="orderNo">{{ $lang.lang.index.orderNo }}:{{ item.orderNo }}</view>
              <view class="marks">{{ $lang.lang.index.marks }}:{{ item.marks }}</view>
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
            </view>
            <view class="item-body">
              <view class="item-body-v">{{ item.departureName }}</view>
              <view class="item-body-v-2">
                <view class="">{{ getStatusName(item.status) }}</view>
                <image src="../../static/img/jiant1.png" mode="widthFix"></image>
              </view>
              <view class="item-body-v">{{ item.objectiveName }}</view>
            </view>
            <view class="item-times">
              <image src="../../static/img/time.png" mode=""></image>
              <text>{{ item.createTime }}</text>
            </view>
          </view>
        </template>
      </view>
    </view>
    <view class="bom">
      <view class="" @click="$request.goPage('../help/help')">
        <image src="../../static/img/help.png" mode=""></image>
        <text>{{ $lang.lang.index.help }}</text>
      </view>
      <view class="" @click="$request.goPage('../consult/consult')">
        <image src="../../static/img/zixun.png" mode=""></image>
        <text>{{ $lang.lang.index.consult }}</text>
      </view>
    </view>
    <uni-popup ref="adpopup" type="center" :mask-click="false">
      <view class="ad-conten">
        <image @click="closeAd" class="ad-bg" src="../../static/img/index_close.png"></image>
honghy's avatar
honghy committed
135
        <view class="ad-title">{{ $lang.locale == 'zh' ? adData.titleZh : $lang.locale == 'en'?adData.titleEn:adData.titleFr }}</view>
136 137
        <view class="ad-info">
          <rich-text
honghy's avatar
honghy committed
138
            :nodes="$lang.locale == 'zh' ? adData.htmlAppZh : $lang.locale == 'en'?adData.htmlAppEn:adData.htmlAppFr"
139 140 141 142 143 144 145 146 147 148 149 150
          ></rich-text>
        </view>
        <view class="ad-btns">
          <view class="ad-btn" @click="closeAd">
            <view>{{ $lang.lang.index.know }}</view>
          </view>
        </view>
      </view>
    </uni-popup>
    <uni-popup ref="choiceTransport" type="center" :mask-click="false">
      <view class="ad-conten type-1">
        <image @click="closeTransport" class="ad-bg1" src="../../static/img/colse1.png"></image>
lanbaoming's avatar
lanbaoming committed
151

152 153 154 155 156 157 158 159 160
        <view class="transport-title">
          <span>{{ $lang.lang.notices.transport }}</span>
        </view>
        <image class="type-bg" src="../../static/img/type-1.png"></image>
        <view class="transport-info">
          <view
            v-for="item in transType"
            @click="toCreatOrder(item.value)"
            :class="'type' + item.value"
honghy's avatar
honghy committed
161
            >{{ $lang.locale == 'zh' ? item.label : $lang.locale == 'en'?item.labelEn:item.labelFr }}</view
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
          >
        </view>
      </view>
    </uni-popup>
    <uni-popup ref="vepopup" type="center" :mask-click="false">
      <view class="ad-conten">
        <image
          v-if="!forceUpdate"
          @click="closeVe"
          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="veData"></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="closeVe">
            <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>
  </view>
lanbaoming's avatar
lanbaoming committed
192 193 194
</template>

<script>
195
import md5 from 'js-md5'
lanbaoming's avatar
lanbaoming committed
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 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
export default {
  data() {
    return {
      nvs: [
        {
          name: this.$lang.lang.index.delivery,
          icon: '../../static/img/express.png',
          url: '../create_order/create_order',
          num: 0
        },
        {
          name: this.$lang.lang.index.order,
          icon: '../../static/img/order.png',
          url: '../order/order',
          num: 0
        },
        // {name: this.$lang.lang.index.consolidation, icon: '../../static/img/order.png', url: '../consolidation/consolidation',num:0},
        // {name: this.$lang.lang.index.coupon, icon: '../../static/img/copue.png', url: '../coupon/coupon',num:0},
        {
          name: this.$lang.lang.index.old_system,
          icon: '../../static/img/copue.png',
          url: '',
          num: 0,
          isHttp: true
        }
        // {name: this.$lang.lang.index.price, icon: '../../static/img/wallet.png', url: '../price_inquiry/price_inquiry',num:0},
      ],
      banner: [],
      orderData: [],
      page: 1,
      isIdcard: false,
      statusData: [],
      name: {},
      adData: {},
      noticeData: [],
      msgHave: false,
      version: '1.0.2',
      appUrl: '',
      veData: '',
      versionCode: 0,
      appVersion: '',
      forceUpdate: 0,
      showdownLine: false,
      downloadNum: 0, //下载百分比
      totalSize: 0, //下载总量
      transType: [],
      preLoginPage: false,
      searchKey: '' //搜索关键词
    }
  },
  onLoad(options) {
    this.getIdcard()
    this.getStatusData()
    this.orderConfig()
    this.getNoticeData()
    this.getVersion()
    this.getAdData()
chenwei's avatar
chenwei committed
254
    this.getMemberSystemStatus()
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269
  },
  onShow() {
    this.getOrder()
    if (this.banner.length == 0) {
      this.getBanner()
    }
    if (this.orderData.length == 0) {
      this.getOrderData()
    }
  },
  methods: {
    toupdate() {
      let that = this
      if (that.showdownLine) return
      // #ifdef APP-PLUS
lanbaoming's avatar
lanbaoming committed
270

271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291
      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
        var dtask = plus.downloader.createDownload(that.appUrl, {}, (d, status) => {
          uni.hideLoading()
          if (status == 200) {
            that.closeVe()
            that.showdownLine = false
            console.log('下载成功安装: ' + d.filename)
            plus.runtime.install(d.filename)
          } else {
            that.showdownLine = false
            that.closeVe()
            plus.nativeUI.alert(that.$lang.lang.notices.failDown)
          }
        })
lanbaoming's avatar
lanbaoming committed
292

293 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
        // uni.navigateTo({
        // 	url:'../updateView/updateView?url='+this.appUrl
        // })
        // 下载进度
        dtask.addEventListener('statechanged', function (download, status) {
          if (that.downloadNum == 100) {
            uni.hideLoading()
          }
          switch (download.state) {
            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
          }
        })
        dtask.start()
      }
      // #endif
    },
chenwei's avatar
chenwei committed
322 323 324 325 326 327 328 329 330 331 332 333
    getMemberSystemStatus(){
      this.$request.get('/admin-api/member/score-rule/switch/get').then((res) => {
        if(res.data){
          this.nvs.push({
          name: this.$lang.lang.index.integral,
          icon: '../../static/img/integral.png',
          url: '/pages/integral/integral',
          num: 0
        })
        }
      })
    },
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351
    getVersion() {
      this.version = uni.getStorageSync('appversion')
      this.versionCode = uni.getStorageSync('versionCode')
      this.getVeData()
    },
    old() {
      const code = md5(md5('jiedaoguoji' + this.userInfo.mobile))
      const url =
        'http://backend.groupage.cn/#/pages/login/free_login?phone=' +
        this.userInfo.mobile +
        '&code=' +
        code +
        '&area_code=+' +
        this.userInfo.areaCode
      // #ifdef APP-PLUS
      plus.runtime.openURL(url)
      // #endif
      // #ifdef H5
lanbaoming's avatar
lanbaoming committed
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
      window.open(url)
      // #endif
    },
    getUserInfo() {
      let that = this
      that.$request.get('/app-api/member/user/get').then((res) => {
        console.log(res.data)
        if (res.code == 0 && res.data) {
          if (res.data.isSimplePassword) {
            uni.showModal({
              title: that.$lang.lang.notices.notice,
              confirmText: that.$lang.lang.site.editPsd,
              cancelText: that.$lang.lang.index.know,
              content: that.$lang.lang.notices.easyPass,
              success: function (res) {
                if (res.confirm) {
                  uni.navigateTo({
                    url: '../editPsd/editPsd'
                  })
                } else if (!that.preLoginPage) {
                  that.openAd()
                  // #ifdef APP-PLUS
                  if (that.appVersion) {
                    that.openVe()
                  }
                  // #endif
                }
              }
            })
          } else if (!that.preLoginPage) {
            that.openAd()
            // #ifdef APP-PLUS
            if (that.appVersion) {
              that.openVe()
            }
            // #endif
          }
          that.userInfo = res.data
391 392 393 394
          // 存储信息节点
          const { id, areaCode } = res.data
          that.$store.commit('SET_ID', id)
          that.$store.commit('SET_AREACODE', areaCode)
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 422 423 424 425 426 427 428 429 430 431 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 467 468 469 470 471 472 473 474 475 476 477 478
        }
      })
    },
    getOrder() {
      this.$request.get('/app-api/member/user/angle-mark').then((res) => {
        if (res.code == 0 && res.data) {
          this.nvs[1].num = res.data.allOrderNum
          this.nvs[2].num = res.data.couponNum
          if (res.data.unreadMessageNum && res.data.unreadMessageNum > 0) {
            this.msgHave = true
          } else {
            this.msgHave = false
          }
        }
      })
    },
    getStatusName(status) {
      var statusName = ''
      let that = this
      if (that.statusData.length > 0) {
        var name = that.statusData.filter((item) => item.value == status) || []
        if (name.length > 0) {
          if (that.$lang.locale == 'zh') {
            statusName = name[0].label
          } else {
            statusName = name[0].labelEn
          }
        }
      }
      return statusName
    },
    openAd() {
      console.log(this.adData)
      if (JSON.stringify(this.adData) != '{}') {
        this.$refs.adpopup.open()
      }
    },
    closeAd() {
      this.preLoginPage = false
      this.$refs.adpopup.close()
    },
    closeTransport() {
      this.$refs.choiceTransport.close()
    },
    openTransport() {
      this.$refs.choiceTransport.open()
    },
    openVe() {
      this.$refs.vepopup.open()
    },
    closeVe() {
      this.$refs.vepopup.close()
      // this.getUserInfo()
    },
    getBanner() {
      this.$request
        .get('/app-api/ecw/banner/page', { page: 1, rows: 20, status: 0 })
        .then((res) => {
          if (res.code == 0 && res.data && res.data.list && res.data.list.length > 0) {
            this.banner = res.data.list
          }
        })
    },
    getOrderData() {
      this.$request
        .get('/app-api/my/order/dynamic/page', { page: this.page, rows: 6 })
        .then((res) => {
          if (res.code == 0 && res.data && res.data.list && res.data.list.length > 0) {
            this.orderData = res.data.list
          }
        })
    },
    getNoticeData() {
      this.$request.get('/app-api/system/notice/page', { page: 1, rows: 6 }).then((res) => {
        if (res.code == 0 && res.data && res.data.list && res.data.list.length > 0) {
          this.noticeData = res.data.list
        }
      })
    },
    getDate(time) {
      const date = new Date(time)
      let year = date.getFullYear()
      let month = date.getMonth() + 1
      let day = date.getDate()
lanbaoming's avatar
lanbaoming committed
479

480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 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 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 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 583 584 585 586 587
      month = month > 9 ? month : '0' + month
      day = day > 9 ? day : '0' + day
      return `${year}-${month}-${day}`
    },
    getAdData() {
      this.$request.get('/app-api/ecw/banner-pop/page', { page: 1, rows: 6 }).then((res) => {
        if (res.code == 0 && res.data && res.data.list && res.data.list.length > 0) {
          this.adData = res.data.list[0]
          let pages = getCurrentPages() // 获取栈实例
          if (pages.length > 1) {
            let prevPage = pages[pages.length - 2]
            if (prevPage && prevPage.route == 'pages/login/login') {
              this.preLoginPage = true
            }
          }
        }
        //#ifdef APP-PLUS
        this.getUserInfo()
        //#endif
        //#ifdef H5
        this.getUserInfo()
        //#endif
      })
    },
    getVeData() {
      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) => {
          console.log(res)
          if (res.code == 0 && res.data) {
            that.veData = res.data.desp
            that.appUrl = res.data.appUrl
            that.appVersion = res.data.appVersion
            that.forceUpdate = res.data.forceUpdate
            // that.openVe()
          } else {
            // that.getUserInfo()
          }
        })
    },
    getStatusData() {
      this.$request.getConfig('order_status').then((res) => {
        if (res.code == 0 && res.data && res.data.list && res.data.list.length > 0) {
          this.statusData = res.data.list
        }
      })
    },
    getIdcard() {
      this.$request.get('/app-api/member/user/get-auth-idcard-info').then((res) => {
        if (res.code == 0 && res.data && res.data.status == 2) {
          this.isIdcard = true
        }
      })
    },
    toPage(url, isHttp) {
      if (isHttp) {
        // window.location.href=url;
        this.old()
      } else {
        if (url == '../create_order/create_order') {
          this.openTransport()
        } else {
          uni.navigateTo({
            url: url
          })
        }
      }
    },
    toCreatOrder(id) {
      this.closeTransport()
      uni.navigateTo({
        url: '../create_order/create_order?transportId=' + id
      })
    },
    toBanner(id) {
      uni.navigateTo({
        url: '../banner_info/banner_info?id=' + id
      })
    },
    toOrderInfo(id) {
      uni.navigateTo({
        url: '../orderInfo/orderInfo?id=' + id
      })
    },
    orderConfig() {
      let that = this
      that.$request.getConfig('transport_type').then((res) => {
        if (res.code == 0 && res.data && res.data.list.length > 0) {
          that.transType = res.data.list
        }
      })
    },
    goPage(url) {
      uni.redirectTo({
        url: url
      })
    },
    toMyOrder() {
      uni.navigateTo({
        url: '../order/order?key=' + this.searchKey
      })
    }
  }
lanbaoming's avatar
lanbaoming committed
588 589 590
}
</script>
<style>
591
@import url(../../static/css/index.css);
lanbaoming's avatar
lanbaoming committed
592
</style>