Commit 27bfa998d96f99a701fcf08d568ebbabaf39d4b8

Authored by sqy
2 parents 0f18827d 2da23875

Merge branch 'main' into sqy_dev

... ... @@ -68,8 +68,8 @@
68 68 <view><u--textarea border="none" height="96" placeholder="请输入处理结果" v-model="formModel.result" count></u--textarea></view>
69 69 </view>
70 70 <!-- #endif -->
71   - <view v-if="list.status !== 'CLEARED_ACK'" style="width: 500rpx;margin-left: 80rpx;margin-top: 44rpx;">
72   - <u-button @click="handleSubmit" type="primary" shape="circle" text="处理"></u-button>
  71 + <view v-if="list.status !== 'CLEARED_ACK'" style="margin-top: 44rpx;">
  72 + <view class="u-flex" style="justify-content: center;align-items: center;"><u-button @click="handleSubmit" type="primary" shape="circle" text="处理"></u-button></view>
73 73 </view>
74 74 </view>
75 75 </template>
... ...
... ... @@ -4,10 +4,10 @@ import {
4 4 let baseUrl = "";
5 5 if (process.env.NODE_ENV === 'development') {
6 6 // 开发环境
7   - baseUrl = 'http://47.99.141.212:8080/api'
  7 + baseUrl = 'https://dev.thingskit.com/api'
8 8 } else if (process.env.NODE_ENV === 'production') {
9 9 // 生产环境
10   - baseUrl = 'http://47.99.141.212:8080/api'
  10 + // baseUrl = 'http://47.99.141.212:8080/api'
11 11 }
12 12
13 13 let systemInfo = {
... ...
... ... @@ -39,7 +39,7 @@ uni.$u.http.interceptors.request.use(
39 39 uni.getStorageSync("userInfo").isToken ||
40 40 undefined;
41 41 }
42   - console.log("请求开始", config);
  42 + // console.log("请求开始", config);
43 43 if (config?.custom?.load) {
44 44 //打开加载动画
45 45 store.commit("setLoadingShow", true);
... ...
... ... @@ -95,7 +95,7 @@ export default {
95 95 ],
96 96 'feedbackInfo.phone': [
97 97 {
98   - type: 'string',
  98 + type: 'number',
99 99 required: true,
100 100 message: '请填写手机号码',
101 101 trigger: ['blur', 'change']
... ... @@ -104,7 +104,7 @@ export default {
104 104 validator: (rule, value, callback) => {
105 105 return uni.$u.test.mobile(value);
106 106 },
107   - message: '手机必须为数字',
  107 + message: '手机号码不正确',
108 108 trigger: ['change', 'blur']
109 109 }
110 110 ],
... ... @@ -119,7 +119,7 @@ export default {
119 119 validator: (rule, value, callback) => {
120 120 return uni.$u.test.email(value);
121 121 },
122   - message: '邮箱必须带有@',
  122 + message: '邮箱不正确',
123 123 trigger: ['change', 'blur']
124 124 }
125 125 ],
... ... @@ -141,6 +141,10 @@ export default {
141 141 }
142 142 };
143 143 },
  144 + onReady() {
  145 + // 如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则
  146 + this.$refs.myfeedBackFormRef.setRules(this.rules);
  147 + },
144 148 onLoad() {
145 149 // 隐藏原生的tabbar
146 150 uni.hideTabBar();
... ...
... ... @@ -158,17 +158,7 @@
158 158 :rules="rules"
159 159 ref="form1"
160 160 >
161   - <u-form-item
162   - style="font-size: 14px"
163   - label="选择日期"
164   - prop="selectTime"
165   - labelWidth="80"
166   - borderBottom
167   - @click="
168   - showCalendar = true;
169   - hideKeyboard();
170   - "
171   - >
  161 + <u-form-item style="font-size: 14px" label="选择日期" prop="selectTime" labelWidth="80" borderBottom @click="openTime">
172 162 <u--input v-model="timeData.selectTime" placeholder="请选择日期" border="none"></u--input>
173 163 </u-form-item>
174 164 </u--form>
... ... @@ -404,7 +394,8 @@ export default {
404 394 this.show = true;
405 395 this.resetData();
406 396 },
407   - hideKeyboard() {
  397 + openTime() {
  398 + this.showCalendar = true;
408 399 uni.hideKeyboard();
409 400 },
410 401 calendarConfirm(e) {
... ... @@ -427,7 +418,7 @@ export default {
427 418 status: e.status
428 419 };
429 420 uni.navigateTo({
430   - url:'/alarmSubPage/alarmDetailPage/alarmDetail?data='+JSON.stringify(obj)
  421 + url: '/alarmSubPage/alarmDetailPage/alarmDetail?data=' + JSON.stringify(obj)
431 422 // url: '/' + JSON.stringify(obj)
432 423 });
433 424 }
... ...
... ... @@ -151,6 +151,7 @@
151 151 background: #ffffff;
152 152 border-radius: 20rpx;
153 153 overflow-y: scroll;
  154 + overflow-x: hidden;
154 155
155 156 .popup-text {
156 157 text-align: center;
... ...
... ... @@ -12,99 +12,93 @@
12 12 </view>
13 13 <view class="org-item"><image class="image" src="../../../static/right-arrow.png"></image></view>
14 14 </view>
15   - <view class="camera-container">
16   - <view class="container-item">
17   - <view @click="openCameraDetail(item.url)" v-for="(item, index) in list" :key="index" class="item">
18   - <video class="video" :src="item.videoUrl" controls></video>
19   - <view class="bottom-text">
20   - <text class="text">{{ item.name }}</text>
21   - </view>
22   - <view @click="hideImageUrl(item, index)" :style="[index == current ? { display: 'none' } : { display: 'block' }]" class="avatar-cover">
23   - <image class="image" :src="item.avatar"></image>
  15 + <!-- 自带分页组件 -->
  16 + <mescroll-body ref="mescrollRef" :up="upOption" @init="mescrollInit" :down="downOption" @down="downCallback" @up="upCallback">
  17 + <view class="camera-container">
  18 + <view class="container-item">
  19 + <view @click="openCameraDetail(item.url)" v-for="(item, index) in list" :key="index" class="item">
  20 + <video class="video" :src="item.videoUrl" controls></video>
  21 + <view class="bottom-text">
  22 + <text class="text">{{ item.name }}</text>
  23 + </view>
  24 + <!-- #ifdef MP -->
  25 + <view @click="hideImageUrl(item, index)" :style="[index == current ? { display: 'none' } : { display: 'block' }]" class="avatar-cover">
  26 + <image class="image" :src="item.avatar"></image>
  27 + </view>
  28 + <!-- #endif -->
24 29 </view>
25 30 </view>
26 31 </view>
27   - </view>
  32 + </mescroll-body>
  33 + <!-- 自带分页组件 -->
28 34 <view style="height: 30rpx;"></view>
29 35 </view>
30 36 </template>
31 37
32 38 <script>
  39 +import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js';
  40 +
33 41 export default {
  42 + mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件)
34 43 data() {
35 44 return {
  45 + page: {
  46 + num: 0,
  47 + size: 10
  48 + },
  49 + downOption: {
  50 + auto: true //是否在初始化后,自动执行downCallback; 默认true
  51 + },
  52 + upOption: {
  53 + auto: false // 不自动加载
  54 + },
36 55 current: 0,
37 56 deviceTotal: 0,
38   - list: [
39   - {
40   - videoUrl: 'http://113.204.115.250:83/openUrl/e5NZg76/live.m3u8',
41   - name: '摄像头1',
42   - avatar: 'http://47.99.141.212:9000/yunteng/bdNZzPQReLufzqx.jpg'
43   - },
44   - {
45   - videoUrl: 'https://klxxcdn.oss-cn-hangzhou.aliyuncs.com/histudy/hrm/media/bg2.mp4',
46   - name: '摄像头2',
47   - avatar: 'http://47.99.141.212:9000/yunteng/bdNZzPQReLufzqx.jpg'
48   - },
49   - {
50   - videoUrl: 'https://stream7.iqilu.com/10339/article/202002/18/2fca1c77730e54c7b500573c2437003f.mp4',
51   - name: '摄像头3',
52   - avatar: 'http://47.99.141.212:9000/yunteng/bdNZzPQReLufzqx.jpg'
53   - },
54   - {
55   - videoUrl: 'https://stream7.iqilu.com/10339/article/202002/17/c292033ef110de9f42d7d539fe0423cf.mp4',
56   - name: '摄像头4',
57   - avatar: 'http://47.99.141.212:9000/yunteng/bdNZzPQReLufzqx.jpg'
58   - },
59   - {
60   - videoUrl: 'https://stream7.iqilu.com/10339/article/202002/16/3be2e4ef4aa21bfe7493064a7415c34d.mp4',
61   - name: '摄像头5',
62   - avatar: 'http://47.99.141.212:9000/yunteng/bdNZzPQReLufzqx.jpg'
63   - },
64   - {
65   - videoUrl: 'https://stream7.iqilu.com/10339/upload_transcode/202002/09/20200209104902N3v5Vpxuvb.mp4',
66   - name: '摄像头6',
67   - avatar: 'http://47.99.141.212:9000/yunteng/bdNZzPQReLufzqx.jpg'
68   - },
69   - {
70   - videoUrl: 'https://stream7.iqilu.com/10339/upload_transcode/202002/09/20200209104902N3v5Vpxuvb.mp4',
71   - name: '摄像头6',
72   - avatar: 'http://47.99.141.212:9000/yunteng/bdNZzPQReLufzqx.jpg'
73   - },
74   - {
75   - videoUrl: 'https://stream7.iqilu.com/10339/upload_transcode/202002/09/20200209104902N3v5Vpxuvb.mp4',
76   - name: '摄像头6',
77   - avatar: 'http://47.99.141.212:9000/yunteng/bdNZzPQReLufzqx.jpg'
78   - },
79   - {
80   - videoUrl: 'https://stream7.iqilu.com/10339/upload_transcode/202002/09/20200209104902N3v5Vpxuvb.mp4',
81   - name: '摄像头6',
82   - avatar: 'http://47.99.141.212:9000/yunteng/bdNZzPQReLufzqx.jpg'
83   - }
84   - ]
  57 + list: []
85 58 };
86 59 },
87 60 onLoad() {
88 61 // 隐藏原生的tabbar
89 62 uni.hideTabBar();
90 63 this.getDeviceTotalData();
91   - this.getCameraList();
92 64 },
93 65 methods: {
94   - hideImageUrl(item, index) {
95   - this.current = index;
  66 + /*下拉刷新的回调 */
  67 + downCallback() {
  68 + //联网加载数据
  69 + this.page.num = 1;
  70 + this.loadData(1);
96 71 },
97   - getCameraList() {
  72 + /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  73 + upCallback() {
  74 + //联网加载数据
  75 + this.page.num += 1;
  76 + this.loadData(this.page.num);
  77 + },
  78 + loadData(pageNo) {
98 79 let httpData = {
99   - page: 1,
  80 + page: pageNo,
100 81 pageSize: 10
101 82 };
102   - uni.$u.http.get('/yt/video', { params: httpData, custom: { load: false } }).then(res => {
103   - if (res) {
104   - console.log('Video', res);
105   - this.list = res.items;
106   - }
107   - });
  83 + uni.$u.http
  84 + .get('/yt/video', { params: httpData, custom: { load: false } })
  85 + .then(res => {
  86 + uni.stopPullDownRefresh();
  87 + this.mescroll.endByPage(res.items.length, res.total);
  88 + if (pageNo == 1) {
  89 + this.list = res.items;
  90 + } else {
  91 + this.list = this.list.concat(res.items);
  92 + }
  93 + })
  94 + .catch(e => {
  95 + uni.$u.toast(e.data?.message);
  96 + //联网失败, 结束加载
  97 + this.mescroll.endErr();
  98 + });
  99 + },
  100 + hideImageUrl(item, index) {
  101 + this.current = index;
108 102 },
109 103 getDeviceTotalData() {
110 104 let httpData = {
... ...
... ... @@ -84,7 +84,7 @@
84 84 }
85 85 .avatar-cover {
86 86 position: relative;
87   - top: -244rpx;
  87 + top: -250rpx;
88 88 border: 0.1rpx splid #fff;
89 89 height: 200rpx;
90 90 .image {
... ...
1 1 <template>
2   - <view class="personal">
3   - <!-- 公共组件-每个页面必须引入 -->
4   - <public-module></public-module>
5   - <view class="headBox">
6   - <!-- #ifdef MP -->
7   - <!-- 登录 -->
8   - <view class="u-flex u-p-l-30 u-p-r-20 u-p-t-75 u-p-b-30">
9   - <block v-if="userInfo.isToken">
10   - <view @click="openPersonalInfo" class="u-m-r-20"><image class="avatar" mode="aspectFill" :src="userInfo.avatar"></image></view>
11   - <view @click="openPersonalInfo" class="u-flex-1">
12   - <view class="nickName u-flex">
13   - <view class="name u-m-r-10" v-if="userInfo.realName">
14   - <text style="#FFFFFF;font-size: 18px;">{{ userInfo.realName }}</text>
15   - </view>
16   - </view>
17   - <view style="#FFFFFF;font-size: 14px;" v-if="userInfo.phoneNumber">手机号:{{ userInfo.phoneNumber | phone }}</view>
18   - <view v-else><text style="#FFFFFF;font-size: 14px;">手机号:未绑定</text></view>
19   - </view>
20   - </block>
21   - <block v-else>
22   - <view class="u-m-r-20">
23   - <view class="avatar u-flex"><u-icon name="account-fill" color="black" size="30"></u-icon></view>
24   - </view>
25   - <view class="u-flex-1">
26   - <view @click="openLoginFunc" class="u-font-lg click-login">请点击登录</view>
27   - <view @click="clickAccountFunc" class="detail"><text class="text">绑定账号</text></view>
28   - </view>
29   - </block>
30   - <view><u-icon name="arrow-right" color="black" size="13"></u-icon></view>
31   - </view>
32   - <!-- #endif -->
33   - <!-- #ifndef MP -->
34   - <!-- 登录 -->
35   - <view class="u-flex u-p-l-30 u-p-r-20 u-p-t-75 u-p-b-30">
36   - <block v-if="userInfo.isToken">
37   - <view @click="openPersonalInfo" class="u-m-r-20"><image class="avatar" mode="aspectFill" :src="userInfo.avatar"></image></view>
38   - <view @click="openPersonalInfo" class="u-flex-1">
39   - <view class="nickName u-flex">
40   - <view class="name u-m-r-10" v-if="userInfo.realName">
41   - <text style="#FFFFFF;font-size: 18px;">{{ userInfo.realName }}</text>
42   - </view>
43   - </view>
44   - <view style="#FFFFFF;font-size: 14px;" v-if="userInfo.phoneNumber">手机号:{{ userInfo.phoneNumber | phone }}</view>
45   - <view v-else><text style="#FFFFFF;font-size: 14px;">手机号:未绑定</text></view>
46   - </view>
47   - </block>
48   - <block v-else>
49   - <view class="u-m-r-20">
50   - <view class="avatar u-flex" style="justify-content: center;"><u-icon name="account-fill" color="black" size="30"></u-icon></view>
51   - </view>
52   - <view class="u-flex-1">
53   - <view @click="openLoginFunc" class="u-font-lg" style="color: black;font-weight: bold;">登录</view>
54   - <view @click="clickAccountFunc" style="color:black;" class="detail">绑定账号</view>
55   - </view>
56   - </block>
57   - <view><u-icon name="arrow-right" color="black" size="13"></u-icon></view>
58   - </view>
59   - <!-- #endif -->
60   - </view>
61   - <view class="u-flex my-nav">
62   - <view class="nav-main">
63   - <view @click="onTokenJump('/sysNotifySubPage/sysNotifyPage/systemNotify')" class="u-flex nav-link">
64   - <view class="nav-image"><image class="image" src="../../static/sys-not.png"></image></view>
65   - <view class="nav-center"><text class="text">系统通知</text></view>
66   - <view class="nav-right"><image class="image" src="../../static/arrow-right.png"></image></view>
67   - </view>
68   - <view @click="onTokenJump('/feedBackSubPage/feedback/feedback')" class="u-flex nav-link">
69   - <view class="nav-image"><image class="image" src="../../static/find-sugg.png"></image></view>
70   - <view class="nav-center"><text class="text">意见反馈</text></view>
71   - <view class="nav-right"><image class="image" src="../../static/arrow-right.png"></image></view>
72   - </view>
73   - </view>
74   - <view v-if="userInfo.isToken" class="u-flex" style="justify-content: center;width: 600rpx;">
75   - <u-button @click="onLoginoutFunc" type="primary" shape="circle" text="退出账号"></u-button>
76   - </view>
77   - </view>
78   - <!-- 绑定账号 -->
79   - <view>
80   - <u-modal :showConfirmButton="false" :show="show" :title="title">
81   - <view v-if="!bindPhone" class="loginPhone">
82   - <view class="form-row"><u--input shape="circle" class="input" prefixIcon="account-fill" type="text" placeholder="登录账号" v-model="account"></u--input></view>
83   - <view class="form-row item-bind">
84   - <u--input
85   - class="input"
86   - shape="circle"
87   - prefixIcon="lock-fill"
88   - suffixIconStyle="color: #909399"
89   - type="password"
90   - placeholder="登录密码"
91   - v-model="password"
92   - @change="passwordChange"
93   - ></u--input>
94   - </view>
95   - <view class="u-flex item-phone">
96   - <view class="phone-hide">手机验证码登录</view>
97   - <view class="bind-phone-text" @click="bindPhoneFunc">手机绑定</view>
98   - </view>
99   - </view>
100   - <view v-else class="loginPhone">
101   - <view class="form-row">
102   - <u--input
103   - shape="circle"
104   - class="input"
105   - type="text"
106   - v-model="phone"
107   - placeholder="请输入手机号码"
108   - placeholder-style="font-weight:normal;color:#bbbbbb;"
109   - ></u--input>
110   - </view>
111   - <view class="form-row row-top">
112   - <u--input
113   - shape="circle"
114   - class="input"
115   - type="text"
116   - v-model="vCode"
117   - placeholder="请输入验证码"
118   - placeholder-style="font-weight:normal;color:#bbbbbb;"
119   - ></u--input>
120   - <view style="color:#377DFF" class="getvcode" :class="{ forhidden: readonly }" @click="getVcode">{{ codeText }}</view>
121   - </view>
122   - <view class="u-flex item-phone">
123   - <view class="phone-hide">手机验证码登录</view>
124   - <view class="bind-phone-text" @click="bindAccountFunc">账号绑定</view>
125   - </view>
126   - </view>
127   - <view class="bottom-content">
128   - <view class="u-flex content">
129   - <view class="cancel"><u-button @click="show = false" type="info" shape="circle" text="取消"></u-button></view>
130   - <view class="confrim"><u-button @click="bindConfirm" type="primary" shape="circle" text="确认"></u-button></view>
131   - </view>
132   - </view>
133   - </u-modal>
134   - </view>
135   - <!-- 退出登录 -->
136   - <view>
137   - <u-popup bgColor="transparent" :overlay="true" :show="showLogout" mode="bottom">
138   - <view class="u-flex logout-main">
139   - <view class="main"><text style="color:#999999">确定要退出当前账号?</text></view>
140   - <view @click="logoutBtn" class="main"><text style="color:#f95e5a">退出登录</text></view>
141   - <view class="main"><text @click="closeLogout" style="color:#3478f7">取消</text></view>
142   - </view>
143   - </u-popup>
144   - </view>
145   - <!-- 退出登录 -->
146   - <f-tabbar></f-tabbar>
147   - </view>
  2 + <view class="personal">
  3 + <!-- 公共组件-每个页面必须引入 -->
  4 + <public-module></public-module>
  5 + <view class="headBox">
  6 + <!-- #ifdef MP -->
  7 + <!-- 登录 -->
  8 + <view class="u-flex u-p-l-30 u-p-r-20 u-p-t-75 u-p-b-30">
  9 + <block v-if="userInfo.isToken">
  10 + <view @click="openPersonalInfo" class="u-m-r-20"
  11 + ><image
  12 + class="avatar"
  13 + mode="aspectFill"
  14 + :src="userInfo.avatar || '/static/default.png'"
  15 + ></image
  16 + ></view>
  17 + <view @click="openPersonalInfo" class="u-flex-1">
  18 + <view class="nickName u-flex">
  19 + <view class="name u-m-r-10" v-if="userInfo.realName">
  20 + <text style="#FFFFFF;font-size: 18px;">{{
  21 + userInfo.realName
  22 + }}</text>
  23 + </view>
  24 + </view>
  25 + <view style="#FFFFFF;font-size: 14px;" v-if="userInfo.phoneNumber"
  26 + >手机号:{{ userInfo.phoneNumber | phone }}</view
  27 + >
  28 + <view v-else
  29 + ><text style="#FFFFFF;font-size: 14px;">手机号:未绑定</text></view
  30 + >
  31 + </view>
  32 + </block>
  33 + <block v-else>
  34 + <view class="u-m-r-20">
  35 + <view class="avatar u-flex"
  36 + ><u-icon name="account-fill" color="black" size="30"></u-icon
  37 + ></view>
  38 + </view>
  39 + <view class="u-flex-1">
  40 + <view @click="openLoginFunc" class="u-font-lg click-login"
  41 + >请点击登录</view
  42 + >
  43 + <view @click="clickAccountFunc" class="detail"
  44 + ><text class="text">绑定账号</text></view
  45 + >
  46 + </view>
  47 + </block>
  48 + <view
  49 + ><u-icon name="arrow-right" color="black" size="13"></u-icon
  50 + ></view>
  51 + </view>
  52 + <!-- #endif -->
  53 + <!-- #ifndef MP -->
  54 + <!-- 登录 -->
  55 + <view class="u-flex u-p-l-30 u-p-r-20 u-p-t-75 u-p-b-30">
  56 + <block v-if="userInfo.isToken">
  57 + <view @click="openPersonalInfo" class="u-m-r-20"
  58 + ><image
  59 + class="avatar"
  60 + mode="aspectFill"
  61 + :src="userInfo.avatar || '/static/default.png'"
  62 + ></image
  63 + ></view>
  64 + <view @click="openPersonalInfo" class="u-flex-1">
  65 + <view class="nickName u-flex">
  66 + <view class="name u-m-r-10" v-if="userInfo.realName">
  67 + <text style="#FFFFFF;font-size: 18px;">{{
  68 + userInfo.realName
  69 + }}</text>
  70 + </view>
  71 + </view>
  72 + <view style="#FFFFFF;font-size: 14px;" v-if="userInfo.phoneNumber"
  73 + >手机号:{{ userInfo.phoneNumber | phone }}</view
  74 + >
  75 + <view v-else
  76 + ><text style="#FFFFFF;font-size: 14px;">手机号:未绑定</text></view
  77 + >
  78 + </view>
  79 + </block>
  80 + <block v-else>
  81 + <view class="u-m-r-20">
  82 + <view class="avatar u-flex" style="justify-content: center"
  83 + ><u-icon name="account-fill" color="black" size="30"></u-icon
  84 + ></view>
  85 + </view>
  86 + <view class="u-flex-1">
  87 + <view
  88 + @click="openLoginFunc"
  89 + class="u-font-lg"
  90 + style="color: black; font-weight: bold"
  91 + >登录</view
  92 + >
  93 + <view @click="clickAccountFunc" style="color: black" class="detail"
  94 + >绑定账号</view
  95 + >
  96 + </view>
  97 + </block>
  98 + <view
  99 + ><u-icon name="arrow-right" color="black" size="13"></u-icon
  100 + ></view>
  101 + </view>
  102 + <!-- #endif -->
  103 + </view>
  104 + <view class="u-flex my-nav">
  105 + <view class="nav-main">
  106 + <view
  107 + @click="onTokenJump('/sysNotifySubPage/sysNotifyPage/systemNotify')"
  108 + class="u-flex nav-link"
  109 + >
  110 + <view class="nav-image"
  111 + ><image class="image" src="../../static/sys-not.png"></image
  112 + ></view>
  113 + <view class="nav-center"><text class="text">系统通知</text></view>
  114 + <view class="nav-right"
  115 + ><image class="image" src="../../static/arrow-right.png"></image
  116 + ></view>
  117 + </view>
  118 + <view
  119 + @click="onTokenJump('/feedBackSubPage/feedback/feedback')"
  120 + class="u-flex nav-link"
  121 + >
  122 + <view class="nav-image"
  123 + ><image class="image" src="../../static/find-sugg.png"></image
  124 + ></view>
  125 + <view class="nav-center"><text class="text">意见反馈</text></view>
  126 + <view class="nav-right"
  127 + ><image class="image" src="../../static/arrow-right.png"></image
  128 + ></view>
  129 + </view>
  130 + </view>
  131 + <view
  132 + v-if="userInfo.isToken"
  133 + class="u-flex"
  134 + style="justify-content: center; width: 600rpx"
  135 + >
  136 + <u-button
  137 + @click="onLoginoutFunc"
  138 + type="primary"
  139 + shape="circle"
  140 + text="退出账号"
  141 + ></u-button>
  142 + </view>
  143 + </view>
  144 + <!-- 绑定账号 -->
  145 + <view>
  146 + <u-modal :showConfirmButton="false" :show="show" :title="title">
  147 + <view v-if="!bindPhone" class="loginPhone">
  148 + <view class="form-row"
  149 + ><u--input
  150 + shape="circle"
  151 + class="input"
  152 + prefixIcon="account-fill"
  153 + type="text"
  154 + placeholder="登录账号"
  155 + v-model="account"
  156 + ></u--input
  157 + ></view>
  158 + <view class="form-row item-bind">
  159 + <u--input
  160 + class="input"
  161 + shape="circle"
  162 + prefixIcon="lock-fill"
  163 + suffixIconStyle="color: #909399"
  164 + type="password"
  165 + placeholder="登录密码"
  166 + v-model="password"
  167 + @change="passwordChange"
  168 + ></u--input>
  169 + </view>
  170 + <view class="u-flex item-phone">
  171 + <view class="phone-hide">手机验证码登录</view>
  172 + <view class="bind-phone-text" @click="bindPhoneFunc">手机绑定</view>
  173 + </view>
  174 + </view>
  175 + <view v-else class="loginPhone">
  176 + <view class="form-row">
  177 + <u--input
  178 + shape="circle"
  179 + class="input"
  180 + type="text"
  181 + v-model="phone"
  182 + placeholder="请输入手机号码"
  183 + placeholder-style="font-weight:normal;color:#bbbbbb;"
  184 + ></u--input>
  185 + </view>
  186 + <view class="form-row row-top">
  187 + <u--input
  188 + shape="circle"
  189 + class="input"
  190 + type="text"
  191 + v-model="vCode"
  192 + placeholder="请输入验证码"
  193 + placeholder-style="font-weight:normal;color:#bbbbbb;"
  194 + ></u--input>
  195 + <view
  196 + style="color: #377dff"
  197 + class="getvcode"
  198 + :class="{ forhidden: readonly }"
  199 + @click="getVcode"
  200 + >{{ codeText }}</view
  201 + >
  202 + </view>
  203 + <view class="u-flex item-phone">
  204 + <view class="phone-hide">手机验证码登录</view>
  205 + <view class="bind-phone-text" @click="bindAccountFunc"
  206 + >账号绑定</view
  207 + >
  208 + </view>
  209 + </view>
  210 + <view class="bottom-content">
  211 + <view class="u-flex content">
  212 + <view class="cancel"
  213 + ><u-button
  214 + @click="show = false"
  215 + type="info"
  216 + shape="circle"
  217 + text="取消"
  218 + ></u-button
  219 + ></view>
  220 + <view class="confrim"
  221 + ><u-button
  222 + @click="bindConfirm"
  223 + type="primary"
  224 + shape="circle"
  225 + text="确认"
  226 + ></u-button
  227 + ></view>
  228 + </view>
  229 + </view>
  230 + </u-modal>
  231 + </view>
  232 + <!-- 退出登录 -->
  233 + <view>
  234 + <u-popup
  235 + bgColor="transparent"
  236 + :overlay="true"
  237 + :show="showLogout"
  238 + mode="bottom"
  239 + >
  240 + <view class="u-flex logout-main">
  241 + <view class="main"
  242 + ><text style="color: #999999">确定要退出当前账号?</text></view
  243 + >
  244 + <view @click="logoutBtn" class="main"
  245 + ><text style="color: #f95e5a">退出登录</text></view
  246 + >
  247 + <view class="main"
  248 + ><text @click="closeLogout" style="color: #3478f7">取消</text></view
  249 + >
  250 + </view>
  251 + </u-popup>
  252 + </view>
  253 + <!-- 退出登录 -->
  254 + <f-tabbar></f-tabbar>
  255 + </view>
148 256 </template>
149 257
150 258 <script>
151 259 var clear;
152   -import base from '@/config/baseUrl';
153   -import fTabbar from '@/components/module/f-tabbar/f-tabbar';
154   -import fNavbar from '@/components/module/f-navbar/f-navbar';
155   -import { mapState, mapMutations } from 'vuex';
  260 +import base from "@/config/baseUrl";
  261 +import fTabbar from "@/components/module/f-tabbar/f-tabbar";
  262 +import fNavbar from "@/components/module/f-navbar/f-navbar";
  263 +import { mapState, mapMutations } from "vuex";
156 264
157 265 export default {
158   - components: {
159   - fTabbar,
160   - fNavbar
161   - },
162   - data() {
163   - return {
164   - PrimaryColor: '#0079fe', //主题色
165   - showLogout: false,
166   - readonly: false,
167   - codeText: '获取验证码',
168   - phone: '', //号码
169   - vCode: '', //验证码
170   - tips: '验证码',
171   - bindPhone: false,
172   - show: false,
173   - title: '绑定账号',
174   - systemInfo: base.systemInfo,
175   - PrimaryButtonColor: '#0079fe', //主题色
176   - };
177   - },
178   - onLoad() {
179   - // 隐藏原生的tabbar
180   - uni.hideTabBar();
181   - },
182   - computed: {
183   - ...mapState(['userInfo'])
184   - },
185   - methods: {
186   - ...mapMutations(['emptyUserInfo']),
187   - // 跳转前判断登录
188   - onTokenJump(url) {
189   - this.judgeLogin(() => {
190   - uni.navigateTo({
191   - url: url
192   - });
193   - });
194   - },
195   - onJump(url) {
196   - uni.navigateTo({
197   - url: url
198   - });
199   - },
200   - openLoginFunc() {
201   - uni.navigateTo({
202   - url: '/publicLoginSubPage/public/login'
203   - });
204   - },
205   - openPersonalInfo() {
206   - let obj = {
207   - data: this.userInfo
208   - };
209   - uni.navigateTo({
210   - url: '/publicLoginSubPage/other/set?data=' + JSON.stringify(obj)
211   - });
212   - },
213   - clickAccountFunc() {
214   - this.show = true;
215   - },
216   - bindConfirm() {},
217   - bindPhoneFunc() {
218   - this.bindPhone = true;
219   - },
220   - bindAccountFunc() {
221   - this.bindPhone = false;
222   - },
223   - //验证码按钮文字状态
224   - getCodeState() {
225   - const _this = this;
226   - this.readonly = true;
227   - this.codeText = '60S后重新获取';
228   - var s = 60;
229   - clear = setInterval(() => {
230   - s--;
231   - _this.codeText = s + 'S后重新获取';
232   - if (s <= 0) {
233   - clearInterval(clear);
234   - _this.codeText = '获取验证码';
235   - _this.readonly = false;
236   - }
237   - }, 1000);
238   - },
239   - //获取验证码
240   - getVcode() {
241   - console.log('getVcode');
242   - if (this.readonly) {
243   - uni.showToast({
244   - title: '验证码已发送~',
245   - icon: 'none'
246   - });
247   - return;
248   - }
249   - if (this.phone == '') {
250   - uni.showToast({
251   - title: '请输入手机号~',
252   - icon: 'none'
253   - });
254   - return;
255   - }
256   - const phoneRegular = /^1\d{10}$/;
257   - if (!phoneRegular.test(this.phone)) {
258   - uni.showToast({
259   - title: '手机号格式不正确~',
260   - icon: 'none'
261   - });
262   - return;
263   - }
264   - let httpData = {};
265   - // 获取验证码接口
266   - // uni.$u.http.post('您的接口', httpData).then(res => {
267   - this.getCodeState(); //开始倒计时
268   - // })
269   - },
270   - onLoginoutFunc() {
271   - this.showLogout = true;
272   - },
273   - closeLogout() {
274   - this.showLogout = false;
275   - },
276   - logoutBtn() {
277   - let that = this;
278   - uni.showModal({
279   - title: '退出登录',
280   - content: '你确定退出登录吗?',
281   - success(res) {
282   - if (res.confirm) {
283   - that.emptyUserInfo();
284   - that.showLogout = false;
285   - setTimeout(() => {
286   - uni.navigateTo({
287   - url: '/publicLoginSubPage/public/login'
288   - });
289   - }, 500);
290   - } else if (res.cancel) {
291   - }
292   - }
293   - });
294   - }
295   - }
  266 + components: {
  267 + fTabbar,
  268 + fNavbar,
  269 + },
  270 + data() {
  271 + return {
  272 + PrimaryColor: "#0079fe", //主题色
  273 + showLogout: false,
  274 + readonly: false,
  275 + codeText: "获取验证码",
  276 + phone: "", //号码
  277 + vCode: "", //验证码
  278 + tips: "验证码",
  279 + bindPhone: false,
  280 + show: false,
  281 + title: "绑定账号",
  282 + systemInfo: base.systemInfo,
  283 + PrimaryButtonColor: "#0079fe", //主题色
  284 + };
  285 + },
  286 + onLoad() {
  287 + // 隐藏原生的tabbar
  288 + uni.hideTabBar();
  289 + },
  290 + computed: {
  291 + ...mapState(["userInfo"]),
  292 + },
  293 + methods: {
  294 + ...mapMutations(["emptyUserInfo"]),
  295 + // 跳转前判断登录
  296 + onTokenJump(url) {
  297 + this.judgeLogin(() => {
  298 + uni.navigateTo({
  299 + url: url,
  300 + });
  301 + });
  302 + },
  303 + onJump(url) {
  304 + uni.navigateTo({
  305 + url: url,
  306 + });
  307 + },
  308 + openLoginFunc() {
  309 + uni.navigateTo({
  310 + url: "/publicLoginSubPage/public/login",
  311 + });
  312 + },
  313 + openPersonalInfo() {
  314 + let obj = {
  315 + data: this.userInfo,
  316 + };
  317 + uni.navigateTo({
  318 + url: "/publicLoginSubPage/other/set?data=" + JSON.stringify(obj),
  319 + });
  320 + },
  321 + clickAccountFunc() {
  322 + this.show = true;
  323 + },
  324 + bindConfirm() {},
  325 + bindPhoneFunc() {
  326 + this.bindPhone = true;
  327 + },
  328 + bindAccountFunc() {
  329 + this.bindPhone = false;
  330 + },
  331 + //验证码按钮文字状态
  332 + getCodeState() {
  333 + const _this = this;
  334 + this.readonly = true;
  335 + this.codeText = "60S后重新获取";
  336 + var s = 60;
  337 + clear = setInterval(() => {
  338 + s--;
  339 + _this.codeText = s + "S后重新获取";
  340 + if (s <= 0) {
  341 + clearInterval(clear);
  342 + _this.codeText = "获取验证码";
  343 + _this.readonly = false;
  344 + }
  345 + }, 1000);
  346 + },
  347 + //获取验证码
  348 + getVcode() {
  349 + console.log("getVcode");
  350 + if (this.readonly) {
  351 + uni.showToast({
  352 + title: "验证码已发送~",
  353 + icon: "none",
  354 + });
  355 + return;
  356 + }
  357 + if (this.phone == "") {
  358 + uni.showToast({
  359 + title: "请输入手机号~",
  360 + icon: "none",
  361 + });
  362 + return;
  363 + }
  364 + const phoneRegular = /^1\d{10}$/;
  365 + if (!phoneRegular.test(this.phone)) {
  366 + uni.showToast({
  367 + title: "手机号格式不正确~",
  368 + icon: "none",
  369 + });
  370 + return;
  371 + }
  372 + let httpData = {};
  373 + // 获取验证码接口
  374 + // uni.$u.http.post('您的接口', httpData).then(res => {
  375 + this.getCodeState(); //开始倒计时
  376 + // })
  377 + },
  378 + onLoginoutFunc() {
  379 + this.showLogout = true;
  380 + },
  381 + closeLogout() {
  382 + this.showLogout = false;
  383 + },
  384 + logoutBtn() {
  385 + let that = this;
  386 + uni.showModal({
  387 + title: "退出登录",
  388 + content: "你确定退出登录吗?",
  389 + success(res) {
  390 + if (res.confirm) {
  391 + that.emptyUserInfo();
  392 + that.showLogout = false;
  393 + setTimeout(() => {
  394 + uni.navigateTo({
  395 + url: "/publicLoginSubPage/public/login",
  396 + });
  397 + }, 500);
  398 + } else if (res.cancel) {
  399 + }
  400 + },
  401 + });
  402 + },
  403 + },
296 404 };
297 405 </script>
298 406
299 407 <style lang="scss" scoped>
300   -@import './static/personal.scss';
  408 +@import "./static/personal.scss";
301 409 </style>
... ...
... ... @@ -137,18 +137,13 @@
137 137 uni.showToast({
138 138 title: '登录成功~',
139 139 icon: 'none'
  140 + }).then(res => {
  141 + uni.reLaunch({
  142 + url: '/pages/personal/personal'
  143 + });
140 144 });
141 145 this.saveUserInfo();
142   - // #ifndef MP
143   - uni.switchTab({
144   - url: './personal'
145   - });
146   - // #endif
147   - // #ifdef MP
148   - uni.switchTab({
149   - url: './personal'
150   - });
151   - // #endif
  146 +
152 147 }
153 148 });
154 149 },
... ...
... ... @@ -164,12 +164,11 @@
164 164 uni.showToast({
165 165 title: '重置密码成功~',
166 166 icon: 'none'
167   - });
168   - setTimeout(() => {
  167 + }).then(res=>{
169 168 uni.navigateBack({
170 169 delta:2
171 170 })
172   - }, 500);
  171 + })
173 172 });
174 173 },
175 174 showPasswordModeF() {
... ...
... ... @@ -3,7 +3,7 @@
3 3 <!-- 公共组件-每个页面必须引入 -->
4 4 <public-module></public-module>
5 5 <view @click="upAvatar" class="u-flex set-main">
6   - <view class="main-image"><image class="image" :src="avatar || '../../static/default-avatar.png'"></image></view>
  6 + <view class="main-image"><image class="image" :src="avatar || '/static/default.png'"></image></view>
7 7 <view class="main-right-image"><image class="image" src="../../static/arrow-right.png"></image></view>
8 8 </view>
9 9 <view class="u-m-t-20 basic-text"><text class="text">基本资料</text></view>
... ...
... ... @@ -4,15 +4,7 @@
4 4 <public-module></public-module>
5 5 <view>
6 6 <u--form labelPosition="left" :model="model1" :rules="rules" ref="form1">
7   - <u-form-item
8   - label="类型"
9   - prop="userInfo.sex"
10   - @click="
11   - showType = true;
12   - hideKeyboard();
13   - "
14   - ref="item1"
15   - >
  7 + <u-form-item label="类型" prop="userInfo.sex" @click="openTypeClick" ref="item1">
16 8 <u--input v-model="model1.userInfo.type" placeholder="请选择类型" border="surround"></u--input>
17 9 <u-icon slot="right" name="arrow-right"></u-icon>
18 10 </u-form-item>
... ... @@ -85,18 +77,27 @@ export default {
85 77 onLoad(e) {
86 78 // 隐藏原生的tabbar
87 79 uni.hideTabBar();
  80 + this.stop();
88 81 },
89 82 methods: {
90   - typeSelect(e) {
91   - this.model1.userInfo.type = e.name;
92   - this.loadData(1, e.value);
  83 + stop() {
  84 + let interval = setInterval(function() {
  85 + uni.hideKeyboard(); //隐藏软键盘
  86 + console.log('刷新');
  87 + }, 20);
93 88 setTimeout(() => {
94   - uni.hideKeyboard();
95   - }, 10);
  89 + clearInterval(interval);
  90 + console.log('停止刷新');
  91 + }, 3000);
96 92 },
97   - hideKeyboard() {
  93 + openTypeClick() {
  94 + this.showType = true;
98 95 uni.hideKeyboard();
99 96 },
  97 + typeSelect(e) {
  98 + this.model1.userInfo.type = e.name;
  99 + this.loadData(1, e.value);
  100 + },
100 101 /*下拉刷新的回调 */
101 102 downCallback() {
102 103 //联网加载数据
... ...
  1 +## 3.0.1(2021-05-13)
  2 +1. 跳转颜色和图标配置
  3 +2. 新增静默更新
  4 +## 3.0.0(2021-05-12)
  5 +1. 支持uni_modules
... ...
  1 +// #ifdef APP-PLUS
  2 +import componentConfig from "@/config/componentConfig"
  3 +const platform = uni.getSystemInfoSync().platform;
  4 +// 主颜色
  5 +const $mainColor = componentConfig.appUpdateColor ? componentConfig.appUpdateColor : "FF5B78";
  6 +// 弹窗图标url
  7 +const $iconUrl = componentConfig.appUpdateIcon ? componentConfig.appUpdateIcon : "/uni_modules/zhouWei-APPUpdate/static/ic_ar.png";
  8 +
  9 +// 获取当前应用的版本号
  10 +export const getCurrentNo = function(callback) {
  11 + // 获取本地应用资源版本号
  12 + plus.runtime.getProperty(plus.runtime.appid, function(inf) {
  13 + callback && callback({
  14 + versionCode: inf.versionCode,
  15 + versionName: inf.version
  16 + });
  17 + });
  18 +}
  19 +// 从服务器下载应用资源包(wgt文件)
  20 +const getDownload = function(data) {
  21 + let dtask;
  22 + if(data.updateType == 'forcibly' || data.updateType == 'solicit'){
  23 + let popupData = {
  24 + progress: true,
  25 + buttonNum: 2
  26 + };
  27 + if(data.updateType == 'forcibly'){
  28 + popupData.buttonNum = 0;
  29 + }
  30 + let lastProgressValue = 0;
  31 + let popupObj = downloadPopup(popupData);
  32 + dtask = plus.downloader.createDownload(data.downloadUrl, {
  33 + filename: "_doc/update/"
  34 + }, function(download, status) {
  35 + if (status == 200) {
  36 + popupObj.change({
  37 + progressValue: 100,
  38 + progressTip:"正在安装文件...",
  39 + progress: true,
  40 + buttonNum: 0
  41 + });
  42 + plus.runtime.install(download.filename, {}, function() {
  43 + popupObj.change({
  44 + contentText: "应用资源更新完成!",
  45 + buttonNum: 1,
  46 + progress: false
  47 + });
  48 + }, function(e) {
  49 + popupObj.cancel();
  50 + plus.nativeUI.alert("安装文件失败[" + e.code + "]:" + e.message);
  51 + });
  52 + } else {
  53 + popupObj.change({
  54 + contentText: "文件下载失败...",
  55 + buttonNum: 1,
  56 + progress: false
  57 + });
  58 + }
  59 + });
  60 + dtask.start();
  61 + dtask.addEventListener("statechanged", function(task, status) {
  62 + switch (task.state) {
  63 + case 1: // 开始
  64 + popupObj.change({
  65 + progressValue:0,
  66 + progressTip:"准备下载...",
  67 + progress: true
  68 + });
  69 + break;
  70 + case 2: // 已连接到服务器
  71 + popupObj.change({
  72 + progressValue:0,
  73 + progressTip:"开始下载...",
  74 + progress: true
  75 + });
  76 + break;
  77 + case 3:
  78 + const progress = parseInt(task.downloadedSize / task.totalSize * 100);
  79 + if(progress - lastProgressValue >= 2){
  80 + lastProgressValue = progress;
  81 + popupObj.change({
  82 + progressValue:progress,
  83 + progressTip: "已下载" + progress + "%",
  84 + progress: true
  85 + });
  86 + }
  87 + break;
  88 + }
  89 + });
  90 + // 取消下载
  91 + popupObj.cancelDownload = function(){
  92 + dtask && dtask.abort();
  93 + uni.showToast({
  94 + title: "已取消下载",
  95 + icon:"none"
  96 + });
  97 + }
  98 + // 重启APP
  99 + popupObj.reboot = function(){
  100 + plus.runtime.restart();
  101 + }
  102 + } else if(data.updateType == "silent"){
  103 + dtask = plus.downloader.createDownload(data.downloadUrl, {
  104 + filename: "_doc/update/"
  105 + }, function(download, status) {
  106 + if (status == 200) {
  107 + plus.runtime.install(download.filename, {}, function() {
  108 + console.log("应用资源更新完成");
  109 + }, function(e) {
  110 + plus.nativeUI.alert("安装文件失败[" + e.code + "]:" + e.message);
  111 + });
  112 + } else {
  113 + plus.nativeUI.alert("文件下载失败...");
  114 + }
  115 + });
  116 + dtask.start();
  117 + }
  118 +}
  119 +// 文字换行
  120 +function drawtext(text, maxWidth) {
  121 + let textArr = text.split("");
  122 + let len = textArr.length;
  123 + // 上个节点
  124 + let previousNode = 0;
  125 + // 记录节点宽度
  126 + let nodeWidth = 0;
  127 + // 文本换行数组
  128 + let rowText = [];
  129 + // 如果是字母,侧保存长度
  130 + let letterWidth = 0;
  131 + // 汉字宽度
  132 + let chineseWidth = 14;
  133 + // otherFont宽度
  134 + let otherWidth = 7;
  135 + for (let i = 0; i < len; i++) {
  136 + if (/[\u4e00-\u9fa5]|[\uFE30-\uFFA0]/g.test(textArr[i])) {
  137 + if(letterWidth > 0){
  138 + if(nodeWidth + chineseWidth + letterWidth * otherWidth > maxWidth){
  139 + rowText.push({
  140 + type: "text",
  141 + content: text.substring(previousNode, i)
  142 + });
  143 + previousNode = i;
  144 + nodeWidth = chineseWidth;
  145 + letterWidth = 0;
  146 + } else {
  147 + nodeWidth += chineseWidth + letterWidth * otherWidth;
  148 + letterWidth = 0;
  149 + }
  150 + } else {
  151 + if(nodeWidth + chineseWidth > maxWidth){
  152 + rowText.push({
  153 + type: "text",
  154 + content: text.substring(previousNode, i)
  155 + });
  156 + previousNode = i;
  157 + nodeWidth = chineseWidth;
  158 + }else{
  159 + nodeWidth += chineseWidth;
  160 + }
  161 + }
  162 + } else {
  163 + if(/\n/g.test(textArr[i])){
  164 + rowText.push({
  165 + type: "break",
  166 + content: text.substring(previousNode, i)
  167 + });
  168 + previousNode = i + 1;
  169 + nodeWidth = 0;
  170 + letterWidth = 0;
  171 + }else if(textArr[i] == "\\" && textArr[i + 1] == "n"){
  172 + rowText.push({
  173 + type: "break",
  174 + content: text.substring(previousNode, i)
  175 + });
  176 + previousNode = i + 2;
  177 + nodeWidth = 0;
  178 + letterWidth = 0;
  179 + }else if(/[a-zA-Z0-9]/g.test(textArr[i])){
  180 + letterWidth += 1;
  181 + if(nodeWidth + letterWidth * otherWidth > maxWidth){
  182 + rowText.push({
  183 + type: "text",
  184 + content: text.substring(previousNode, i + 1 - letterWidth)
  185 + });
  186 + previousNode = i + 1 - letterWidth;
  187 + nodeWidth = letterWidth * otherWidth;
  188 + letterWidth = 0;
  189 + }
  190 + } else{
  191 + if(nodeWidth + otherWidth > maxWidth){
  192 + rowText.push({
  193 + type: "text",
  194 + content: text.substring(previousNode, i)
  195 + });
  196 + previousNode = i;
  197 + nodeWidth = otherWidth;
  198 + }else{
  199 + nodeWidth += otherWidth;
  200 + }
  201 + }
  202 + }
  203 + }
  204 + if (previousNode < len) {
  205 + rowText.push({
  206 + type: "text",
  207 + content: text.substring(previousNode, len)
  208 + });
  209 + }
  210 + return rowText;
  211 +}
  212 +// 是否更新弹窗
  213 +function updatePopup(data, callback) {
  214 + // 弹窗遮罩层
  215 + let maskLayer = new plus.nativeObj.View("maskLayer", { //先创建遮罩层
  216 + top: '0px',
  217 + left: '0px',
  218 + height: '100%',
  219 + width: '100%',
  220 + backgroundColor: 'rgba(0,0,0,0.5)'
  221 + });
  222 +
  223 + // 以下为计算菜单的nview绘制布局,为固定算法,使用者无关关心
  224 + const screenWidth = plus.screen.resolutionWidth;
  225 + const screenHeight = plus.screen.resolutionHeight;
  226 + //弹窗容器宽度
  227 + const popupViewWidth = screenWidth * 0.7;
  228 + // 弹窗容器的Padding
  229 + const viewContentPadding = 20;
  230 + // 弹窗容器的宽度
  231 + const viewContentWidth = parseInt(popupViewWidth - (viewContentPadding * 2));
  232 + // 描述的列表
  233 + const descriptionList = drawtext(data.versionInfo, viewContentWidth);
  234 + // 弹窗容器高度
  235 + let popupViewHeight = 80 + 20 + 20 + 90 + 10;
  236 +
  237 + let popupViewContentList = [{
  238 + src: $iconUrl,
  239 + id: "logo",
  240 + tag: "img",
  241 + position: {
  242 + top: "0px",
  243 + left: (popupViewWidth - 124) / 2 + "px",
  244 + width: "124px",
  245 + height: "80px",
  246 + }
  247 + },
  248 + {
  249 + tag: 'font',
  250 + id: 'title',
  251 + text: "发现新版本" + data.versionName,
  252 + textStyles: {
  253 + size: '18px',
  254 + color: "#333",
  255 + weight: "bold",
  256 + whiteSpace: "normal"
  257 + },
  258 + position: {
  259 + top: '90px',
  260 + left: viewContentPadding + "px",
  261 + width: viewContentWidth + "px",
  262 + height: "30px",
  263 + }
  264 + }];
  265 + const textHeight = 18;
  266 + let contentTop = 130;
  267 + descriptionList.forEach((item,index) => {
  268 + if(index > 0){
  269 + popupViewHeight += textHeight;
  270 + contentTop += textHeight;
  271 + }
  272 + popupViewContentList.push({
  273 + tag: 'font',
  274 + id: 'content' + index + 1,
  275 + text: item.content,
  276 + textStyles: {
  277 + size: '14px',
  278 + color: "#666",
  279 + lineSpacing: "50%",
  280 + align: "left"
  281 + },
  282 + position: {
  283 + top: contentTop + "px",
  284 + left: viewContentPadding + "px",
  285 + width: viewContentWidth + "px",
  286 + height: textHeight + "px",
  287 + }
  288 + });
  289 + if(item.type == "break"){
  290 + contentTop += 10;
  291 + popupViewHeight += 10;
  292 + }
  293 + });
  294 +
  295 + if(data.updateType == "forcibly"){
  296 + popupViewContentList.push({
  297 + tag: 'rect', //绘制底边按钮
  298 + rectStyles:{
  299 + radius: "6px",
  300 + color: $mainColor
  301 + },
  302 + position:{
  303 + bottom: viewContentPadding + 'px',
  304 + left: viewContentPadding + "px",
  305 + width: viewContentWidth + "px",
  306 + height: "30px"
  307 + }
  308 + });
  309 + popupViewContentList.push({
  310 + tag: 'font',
  311 + id: 'confirmText',
  312 + text: "立即升级",
  313 + textStyles: {
  314 + size: '14px',
  315 + color: "#FFF",
  316 + lineSpacing: "0%",
  317 + },
  318 + position: {
  319 + bottom: viewContentPadding + 'px',
  320 + left: viewContentPadding + "px",
  321 + width: viewContentWidth + "px",
  322 + height: "30px"
  323 + }
  324 + });
  325 + } else {
  326 + // 绘制底边按钮
  327 + popupViewContentList.push({
  328 + tag: 'rect',
  329 + id: 'cancelBox',
  330 + rectStyles: {
  331 + radius: "3px",
  332 + borderColor: "#f1f1f1",
  333 + borderWidth: "1px",
  334 + },
  335 + position: {
  336 + bottom: viewContentPadding + 'px',
  337 + left: viewContentPadding + "px",
  338 + width: (viewContentWidth - viewContentPadding) / 2 + "px",
  339 + height: "30px",
  340 + }
  341 + });
  342 + popupViewContentList.push({
  343 + tag: 'rect',
  344 + id: 'confirmBox',
  345 + rectStyles: {
  346 + radius: "3px",
  347 + color: $mainColor,
  348 + },
  349 + position: {
  350 + bottom: viewContentPadding + 'px',
  351 + left: ((viewContentWidth - viewContentPadding) / 2 + viewContentPadding * 2) + "px",
  352 + width: (viewContentWidth - viewContentPadding) / 2 + "px",
  353 + height: "30px",
  354 + }
  355 + });
  356 + popupViewContentList.push({
  357 + tag: 'font',
  358 + id: 'cancelText',
  359 + text: "暂不升级",
  360 + textStyles: {
  361 + size: '14px',
  362 + color: "#666",
  363 + lineSpacing: "0%",
  364 + whiteSpace: "normal"
  365 + },
  366 + position: {
  367 + bottom: viewContentPadding + 'px',
  368 + left: viewContentPadding + "px",
  369 + width: (viewContentWidth - viewContentPadding) / 2 + "px",
  370 + height: "30px",
  371 + }
  372 + });
  373 + popupViewContentList.push({
  374 + tag: 'font',
  375 + id: 'confirmText',
  376 + text: "立即升级",
  377 + textStyles: {
  378 + size: '14px',
  379 + color: "#FFF",
  380 + lineSpacing: "0%",
  381 + whiteSpace: "normal"
  382 + },
  383 + position: {
  384 + bottom: viewContentPadding + 'px',
  385 + left: ((viewContentWidth - viewContentPadding) / 2 + viewContentPadding * 2) + "px",
  386 + width: (viewContentWidth - viewContentPadding) / 2 + "px",
  387 + height: "30px",
  388 + }
  389 + });
  390 + }
  391 + // 弹窗内容
  392 + let popupView = new plus.nativeObj.View("popupView", { //创建底部图标菜单
  393 + tag: "rect",
  394 + top: (screenHeight - popupViewHeight) / 2 + "px",
  395 + left: '15%',
  396 + height: popupViewHeight + "px",
  397 + width: "70%"
  398 + });
  399 + // 绘制白色背景
  400 + popupView.drawRect({
  401 + color: "#FFFFFF",
  402 + radius: "8px"
  403 + }, {
  404 + top: "40px",
  405 + height: popupViewHeight - 40 + "px",
  406 + });
  407 +
  408 + popupView.draw(popupViewContentList);
  409 + popupView.addEventListener("click", function(e) {
  410 + let maxTop = popupViewHeight - viewContentPadding;
  411 + let maxLeft = popupViewWidth - viewContentPadding;
  412 + let buttonWidth = (viewContentWidth - viewContentPadding) / 2;
  413 + if (e.clientY > maxTop - 30 && e.clientY < maxTop) {
  414 + if(data.updateType == "forcibly"){
  415 + if(e.clientX > viewContentPadding && e.clientX < maxLeft){
  416 + // 立即升级
  417 + maskLayer.hide();
  418 + popupView.hide();
  419 + callback && callback();
  420 + }
  421 + } else {
  422 + // 暂不升级
  423 + if (e.clientX > viewContentPadding && e.clientX < maxLeft - buttonWidth - viewContentPadding) {
  424 + maskLayer.hide();
  425 + popupView.hide();
  426 + } else if (e.clientX > maxLeft - buttonWidth && e.clientX < maxLeft) {
  427 + // 立即升级
  428 + maskLayer.hide();
  429 + popupView.hide();
  430 + callback && callback();
  431 + }
  432 + }
  433 +
  434 + }
  435 + });
  436 + if(data.updateType == "solicit"){
  437 + // 点击遮罩层
  438 + maskLayer.addEventListener("click", function() { //处理遮罩层点击
  439 + maskLayer.hide();
  440 + popupView.hide();
  441 + });
  442 + }
  443 + // 显示弹窗
  444 + maskLayer.show();
  445 + popupView.show();
  446 +}
  447 +// 文件下载的弹窗绘图
  448 +function downloadPopupDrawing(data){
  449 + // 以下为计算菜单的nview绘制布局,为固定算法,使用者无关关心
  450 + const screenWidth = plus.screen.resolutionWidth;
  451 + const screenHeight = plus.screen.resolutionHeight;
  452 + //弹窗容器宽度
  453 + const popupViewWidth = screenWidth * 0.7;
  454 + // 弹窗容器的Padding
  455 + const viewContentPadding = 20;
  456 + // 弹窗容器的宽度
  457 + const viewContentWidth = popupViewWidth - (viewContentPadding * 2);
  458 + // 弹窗容器高度
  459 + let popupViewHeight = viewContentPadding * 3 + 60;
  460 + let progressTip = data.progressTip || "准备下载...";
  461 + let contentText = data.contentText || "正在为您更新,请耐心等待";
  462 + let elementList = [
  463 + {
  464 + tag: 'rect', //背景色
  465 + color: '#FFFFFF',
  466 + rectStyles:{
  467 + radius: "8px"
  468 + }
  469 + },
  470 + {
  471 + tag: 'font',
  472 + id: 'title',
  473 + text: "升级APP",
  474 + textStyles: {
  475 + size: '16px',
  476 + color: "#333",
  477 + weight: "bold",
  478 + verticalAlign: "middle",
  479 + whiteSpace: "normal"
  480 + },
  481 + position: {
  482 + top: viewContentPadding + 'px',
  483 + height: "30px",
  484 + }
  485 + },
  486 + {
  487 + tag: 'font',
  488 + id: 'content',
  489 + text: contentText,
  490 + textStyles: {
  491 + size: '14px',
  492 + color: "#333",
  493 + verticalAlign: "middle",
  494 + whiteSpace: "normal"
  495 + },
  496 + position: {
  497 + top: viewContentPadding * 2 + 30 + 'px',
  498 + height: "20px",
  499 + }
  500 + }
  501 + ];
  502 + // 是否有进度条
  503 + if(data.progress){
  504 + popupViewHeight += viewContentPadding + 40;
  505 + elementList = elementList.concat([
  506 + {
  507 + tag: 'font',
  508 + id: 'progressValue',
  509 + text: progressTip,
  510 + textStyles: {
  511 + size: '14px',
  512 + color: $mainColor,
  513 + whiteSpace: "normal"
  514 + },
  515 + position: {
  516 + top: viewContentPadding * 4 + 20 + 'px',
  517 + height: "30px"
  518 + }
  519 + },
  520 + {
  521 + tag: 'rect', //绘制进度条背景
  522 + id: 'progressBg',
  523 + rectStyles:{
  524 + radius: "4px",
  525 + borderColor: "#f1f1f1",
  526 + borderWidth: "1px",
  527 + },
  528 + position:{
  529 + top: viewContentPadding * 4 + 60 + 'px',
  530 + left: viewContentPadding + "px",
  531 + width: viewContentWidth + "px",
  532 + height: "8px"
  533 + }
  534 + },
  535 + ]);
  536 + }
  537 + if (data.buttonNum == 2) {
  538 + popupViewHeight += viewContentPadding + 30;
  539 + elementList = elementList.concat([
  540 + {
  541 + tag: 'rect', //绘制底边按钮
  542 + rectStyles:{
  543 + radius: "3px",
  544 + borderColor: "#f1f1f1",
  545 + borderWidth: "1px",
  546 + },
  547 + position:{
  548 + bottom: viewContentPadding + 'px',
  549 + left: viewContentPadding + "px",
  550 + width: (viewContentWidth - viewContentPadding) / 2 + "px",
  551 + height: "30px"
  552 + }
  553 + },
  554 + {
  555 + tag: 'rect', //绘制底边按钮
  556 + rectStyles:{
  557 + radius: "3px",
  558 + color: $mainColor
  559 + },
  560 + position:{
  561 + bottom: viewContentPadding + 'px',
  562 + left: ((viewContentWidth - viewContentPadding) / 2 + viewContentPadding * 2) + "px",
  563 + width: (viewContentWidth - viewContentPadding) / 2 + "px",
  564 + height: "30px"
  565 + }
  566 + },
  567 + {
  568 + tag: 'font',
  569 + id: 'cancelText',
  570 + text: "取消下载",
  571 + textStyles: {
  572 + size: '14px',
  573 + color: "#666",
  574 + lineSpacing: "0%",
  575 + whiteSpace: "normal"
  576 + },
  577 + position: {
  578 + bottom: viewContentPadding + 'px',
  579 + left: viewContentPadding + "px",
  580 + width: (viewContentWidth - viewContentPadding) / 2 + "px",
  581 + height: "30px",
  582 + }
  583 + },
  584 + {
  585 + tag: 'font',
  586 + id: 'confirmText',
  587 + text: "后台下载",
  588 + textStyles: {
  589 + size: '14px',
  590 + color: "#FFF",
  591 + lineSpacing: "0%",
  592 + whiteSpace: "normal"
  593 + },
  594 + position: {
  595 + bottom: viewContentPadding + 'px',
  596 + left: ((viewContentWidth - viewContentPadding) / 2 + viewContentPadding * 2) + "px",
  597 + width: (viewContentWidth - viewContentPadding) / 2 + "px",
  598 + height: "30px",
  599 + }
  600 + }
  601 + ]);
  602 + }
  603 + if (data.buttonNum == 1) {
  604 + popupViewHeight += viewContentPadding + 40;
  605 + elementList = elementList.concat([
  606 + {
  607 + tag: 'rect', //绘制底边按钮
  608 + rectStyles:{
  609 + radius: "6px",
  610 + color: $mainColor
  611 + },
  612 + position:{
  613 + bottom: viewContentPadding + 'px',
  614 + left: viewContentPadding + "px",
  615 + width: viewContentWidth + "px",
  616 + height: "40px"
  617 + }
  618 + },
  619 + {
  620 + tag: 'font',
  621 + id: 'confirmText',
  622 + text: "关闭",
  623 + textStyles: {
  624 + size: '14px',
  625 + color: "#FFF",
  626 + lineSpacing: "0%",
  627 + },
  628 + position: {
  629 + bottom: viewContentPadding + 'px',
  630 + left: viewContentPadding + "px",
  631 + width: viewContentWidth + "px",
  632 + height: "40px"
  633 + }
  634 + }
  635 + ]);
  636 + }
  637 + return {
  638 + popupViewHeight:popupViewHeight,
  639 + popupViewWidth:popupViewWidth,
  640 + screenHeight:screenHeight,
  641 + viewContentWidth:viewContentWidth,
  642 + viewContentPadding:viewContentPadding,
  643 + elementList: elementList
  644 + };
  645 +}
  646 +// 文件下载的弹窗
  647 +function downloadPopup(data) {
  648 + // 弹窗遮罩层
  649 + let maskLayer = new plus.nativeObj.View("maskLayer", { //先创建遮罩层
  650 + top: '0px',
  651 + left: '0px',
  652 + height: '100%',
  653 + width: '100%',
  654 + backgroundColor: 'rgba(0,0,0,0.5)'
  655 + });
  656 + let popupViewData = downloadPopupDrawing(data);
  657 + // 弹窗内容
  658 + let popupView = new plus.nativeObj.View("popupView", { //创建底部图标菜单
  659 + tag: "rect",
  660 + top: (popupViewData.screenHeight - popupViewData.popupViewHeight) / 2 + "px",
  661 + left: '15%',
  662 + height: popupViewData.popupViewHeight + "px",
  663 + width: "70%",
  664 + });
  665 + let progressValue = 0;
  666 + let progressTip = 0;
  667 + let contentText = 0;
  668 + let buttonNum = 2;
  669 + if(data.buttonNum >= 0){
  670 + buttonNum = data.buttonNum;
  671 + }
  672 + popupView.draw(popupViewData.elementList);
  673 + let callbackData = {
  674 + change: function(res) {
  675 + let progressElement = [];
  676 + if(res.progressValue){
  677 + progressValue = res.progressValue;
  678 + // 绘制进度条
  679 + progressElement.push({
  680 + tag: 'rect', //绘制进度条背景
  681 + id: 'progressValueBg',
  682 + rectStyles:{
  683 + radius: "4px",
  684 + color: $mainColor
  685 + },
  686 + position:{
  687 + top: popupViewData.viewContentPadding * 4 + 60 + 'px',
  688 + left: popupViewData.viewContentPadding + "px",
  689 + width: popupViewData.viewContentWidth * (res.progressValue / 100) + "px",
  690 + height: "8px"
  691 + }
  692 + });
  693 + }
  694 + if(res.progressTip){
  695 + progressTip = res.progressTip;
  696 + progressElement.push({
  697 + tag: 'font',
  698 + id: 'progressValue',
  699 + text: res.progressTip,
  700 + textStyles: {
  701 + size: '14px',
  702 + color: $mainColor,
  703 + whiteSpace: "normal"
  704 + },
  705 + position: {
  706 + top: popupViewData.viewContentPadding * 4 + 20 + 'px',
  707 + height: "30px"
  708 + }
  709 + });
  710 + }
  711 + if(res.contentText){
  712 + contentText = res.contentText;
  713 + progressElement.push({
  714 + tag: 'font',
  715 + id: 'content',
  716 + text: res.contentText,
  717 + textStyles: {
  718 + size: '16px',
  719 + color: "#333",
  720 + whiteSpace: "normal"
  721 + },
  722 + position: {
  723 + top: popupViewData.viewContentPadding * 2 + 30 + 'px',
  724 + height: "30px",
  725 + }
  726 + });
  727 + }
  728 + if(res.buttonNum >= 0 && buttonNum != res.buttonNum){
  729 + buttonNum = res.buttonNum;
  730 + popupView.reset();
  731 + popupViewData = downloadPopupDrawing(Object.assign({
  732 + progressValue:progressValue,
  733 + progressTip:progressTip,
  734 + contentText:contentText,
  735 + },res));
  736 + let newElement = [];
  737 + popupViewData.elementList.map((item,index) => {
  738 + let have = false;
  739 + progressElement.forEach((childItem,childIndex) => {
  740 + if(item.id == childItem.id){
  741 + have = true;
  742 + }
  743 + });
  744 + if(!have){
  745 + newElement.push(item);
  746 + }
  747 + });
  748 + progressElement = newElement.concat(progressElement);
  749 + popupView.setStyle({
  750 + tag: "rect",
  751 + top: (popupViewData.screenHeight - popupViewData.popupViewHeight) / 2 + "px",
  752 + left: '15%',
  753 + height: popupViewData.popupViewHeight + "px",
  754 + width: "70%",
  755 + });
  756 + popupView.draw(progressElement);
  757 + }else{
  758 + popupView.draw(progressElement);
  759 + }
  760 + },
  761 + cancel: function() {
  762 + maskLayer.hide();
  763 + popupView.hide();
  764 + }
  765 + }
  766 + popupView.addEventListener("click", function(e) {
  767 + let maxTop = popupViewData.popupViewHeight - popupViewData.viewContentPadding;
  768 + let maxLeft = popupViewData.popupViewWidth - popupViewData.viewContentPadding;
  769 + if (e.clientY > maxTop - 40 && e.clientY < maxTop) {
  770 + if(buttonNum == 1){
  771 + // 单按钮
  772 + if (e.clientX > popupViewData.viewContentPadding && e.clientX < maxLeft) {
  773 + maskLayer.hide();
  774 + popupView.hide();
  775 + callbackData.reboot();
  776 + }
  777 + }else if(buttonNum == 2){
  778 + // 双按钮
  779 + let buttonWidth = (popupViewData.viewContentWidth - popupViewData.viewContentPadding) / 2;
  780 + if (e.clientX > popupViewData.viewContentPadding && e.clientX < maxLeft - buttonWidth - popupViewData.viewContentPadding) {
  781 + maskLayer.hide();
  782 + popupView.hide();
  783 + callbackData.cancelDownload();
  784 + } else if (e.clientX > maxLeft - buttonWidth && e.clientX < maxLeft) {
  785 + maskLayer.hide();
  786 + popupView.hide();
  787 + }
  788 + }
  789 + }
  790 + });
  791 + // 显示弹窗
  792 + maskLayer.show();
  793 + popupView.show();
  794 + // 改变进度条
  795 + return callbackData;
  796 +}
  797 +export default function(isPrompt = false) {
  798 + getCurrentNo(versionInfo => {
  799 + componentConfig.getServerNo(versionInfo, isPrompt, res => {
  800 + if (res.updateType == "forcibly" || res.updateType == "silent") {
  801 + if (/\.wgt$/i.test(res.downloadUrl)) {
  802 + getDownload(res);
  803 + } else if(/\.html$/i.test(res.downloadUrl)){
  804 + plus.runtime.openURL(res.downloadUrl);
  805 + } else {
  806 + if (platform == "android") {
  807 + getDownload(res);
  808 + } else {
  809 + plus.runtime.openURL(res.downloadUrl);
  810 + }
  811 + }
  812 + } else if(res.updateType == "solicit"){
  813 + updatePopup(res, function() {
  814 + if (/\.wgt$/i.test(res.downloadUrl)) {
  815 + getDownload(res);
  816 + } else if(/\.html$/i.test(res.downloadUrl)){
  817 + plus.runtime.openURL(res.downloadUrl);
  818 + } else {
  819 + if (platform == "android") {
  820 + getDownload(res);
  821 + } else {
  822 + plus.runtime.openURL(res.downloadUrl);
  823 + }
  824 + }
  825 + });
  826 + }
  827 + });
  828 + });
  829 +}
  830 +// #endif
\ No newline at end of file
... ...
  1 +{
  2 + "id": "zhouWei-APPUpdate",
  3 + "displayName": "APP版本更新、强制更新、静默更新、下载进度(wgt更新)",
  4 + "version": "3.0.1",
  5 + "description": "APP版本更新、强制更新、静默更新、漂亮弹窗、下载进度(wgt更新)",
  6 + "keywords": [
  7 + "APP版本更新",
  8 + "强制更新",
  9 + "版本更新",
  10 + "静默更新"
  11 +],
  12 + "repository": "https://github.com/zhouwei1994/uni-app-demo",
  13 + "engines": {
  14 + "HBuilderX": "^3.1.0"
  15 + },
  16 + "dcloudext": {
  17 + "category": [
  18 + "JS SDK",
  19 + "通用 SDK"
  20 + ],
  21 + "sale": {
  22 + "regular": {
  23 + "price": "0.00"
  24 + },
  25 + "sourcecode": {
  26 + "price": "0.00"
  27 + }
  28 + },
  29 + "contact": {
  30 + "qq": "465081029"
  31 + },
  32 + "declaration": {
  33 + "ads": "无",
  34 + "data": "无",
  35 + "permissions": "<uses-permission android:name=\\\"android.permission.INSTALL_PACKAGES\\\"/> \n<uses-permission android:name=\\\"android.permission.REQUEST_INSTALL_PACKAGES\\\"/>"
  36 + },
  37 + "npmurl": ""
  38 + },
  39 + "uni_modules": {
  40 + "dependencies": [],
  41 + "encrypt": [],
  42 + "platforms": {
  43 + "cloud": {
  44 + "tcb": "y",
  45 + "aliyun": "y"
  46 + },
  47 + "client": {
  48 + "App": {
  49 + "app-vue": "y",
  50 + "app-nvue": "y"
  51 + },
  52 + "H5-mobile": {
  53 + "Safari": "n",
  54 + "Android Browser": "n",
  55 + "微信浏览器(Android)": "n",
  56 + "QQ浏览器(Android)": "n"
  57 + },
  58 + "H5-pc": {
  59 + "Chrome": "n",
  60 + "IE": "n",
  61 + "Edge": "n",
  62 + "Firefox": "n",
  63 + "Safari": "n"
  64 + },
  65 + "小程序": {
  66 + "微信": "n",
  67 + "阿里": "n",
  68 + "百度": "n",
  69 + "字节跳动": "n",
  70 + "QQ": "n"
  71 + },
  72 + "快应用": {
  73 + "华为": "n",
  74 + "联盟": "n"
  75 + }
  76 + }
  77 + }
  78 + }
  79 +}
\ No newline at end of file
... ...
  1 +### 常见问题
  2 +1.安卓apk下载完成后没有更新APP?
  3 +
  4 +答:问题是因为没有添加APP安装应用的权限,解决方法在`manifest.json`文件里面`APP模块权限配置`的`Android打包权限配置`勾选以下权限
  5 +```
  6 +<uses-permission android:name=\"android.permission.INSTALL_PACKAGES\"/>
  7 +<uses-permission android:name=\"android.permission.REQUEST_INSTALL_PACKAGES\"/>
  8 +```
  9 +若还有问题请看[安装apk无法执行的解决方案](https://ask.dcloud.net.cn/article/35703 "安装apk无法执行的解决方案")
  10 +
  11 +2.APP更新后版本号没变,还是之前的版本号?
  12 +
  13 +答:可能是更新的安装包没有升级版本号,`manifest.json`文件里面基本设置`应用版本号`和`应用版本名称`需要升高(保持一直减少问题)
  14 +
  15 +3.APP更新后没有覆盖之前的APP?
  16 +
  17 +答:可能是更新的安装包`包名`和APP的`包名`不一样
  18 +
  19 +4.弹窗的图标不显示?
  20 +
  21 +答:检查图片是不是放项目资源文件`static`,然后重新运行项目
  22 +
  23 +5.版本号是在前端对比还是在后端接口对比?
  24 +
  25 +答:当前案例是本地的版本号通过接口传递给后台,是后台对比的,若需要前端对比,请在接口返回数据的地方修改,不更新就不要调用`callback`方法
  26 +
  27 +6.本地的版本号比接口的版本号高还弹窗升级窗口?
  28 +
  29 +答:当前案例是本地的版本号通过接口传递给后台,后台对比是否需要升级,不需要升级就不要返回数据(特别是需要wgt更新的,建议这种方式)
  30 +
  31 +### 第一步`关键`配置APP更新接口(可以参考上面的示例)
  32 +在项目目录下`config/componentConfig.js`里面如下配置
  33 +```
  34 +// 此方法是接口请求方法
  35 +import $http from '@/config/requestConfig'
  36 +export default {
  37 + // 发起ajax请求获取服务端版本号
  38 + getServerNo: (version, isPrompt = false, callback) => {
  39 + let httpData = {
  40 + version: version.versionCode,
  41 + // 版本名称
  42 + versionName: version.versionName,
  43 + // setupPage参数说明(判断用户是不是从设置页面点击的更新,如果是设置页面点击的更新,有不要用静默更新了,不然用户点击没反应很奇怪的)
  44 + setupPage: isPrompt
  45 + };
  46 + if (platform == "android") {
  47 + httpData.type = 1101;
  48 + } else {
  49 + httpData.type = 1102;
  50 + }
  51 + /* 接口入参说明
  52 + * version: 应用当前版本号(已自动获取)
  53 + * versionName: 应用当前版本名称(已自动获取)
  54 + * type:平台(1101是安卓,1102是IOS)
  55 + */
  56 + /****************以下是示例*******************/
  57 + // 可以用自己项目的请求方法(接口自己找后台要,插件不提供)
  58 + $http.get("api/common/v1/app_version", httpData,{
  59 + isPrompt: isPrompt
  60 + }).then(res => {
  61 + /* res的数据说明
  62 + * | 参数名称 | 一定返回 | 类型 | 描述
  63 + * | -------------|--------- | --------- | ------------- |
  64 + * | versionCode | y | int | 版本号 |
  65 + * | versionName | y | String | 版本名称 |
  66 + * | versionInfo | y | String | 版本信息 |
  67 + * | updateType | y | String | forcibly = 强制更新, solicit = 弹窗确认更新, silent = 静默更新 |
  68 + * | downloadUrl | y | String | 版本下载链接(IOS安装包更新请放跳转store应用商店链接,安卓apk和wgt文件放文件下载链接) |
  69 + */
  70 + if (res && res.downloadUrl) {
  71 + // 兼容之前的版本(updateType是新版才有的参数)
  72 + if(res.updateType){
  73 + callback && callback(res);
  74 + } else {
  75 + if(res.forceUpdate){
  76 + res.updateType = "forcibly";
  77 + } else {
  78 + res.updateType = "solicit";
  79 + }
  80 + callback && callback(res);
  81 + }
  82 + } else if (isPrompt) {
  83 + uni.showToast({
  84 + title: "暂无新版本",
  85 + icon: "none"
  86 + });
  87 + }
  88 + });
  89 + /****************以上是示例*******************/
  90 + },
  91 + // 弹窗主颜色(不填默认粉色)
  92 + appUpdateColor: "f00",
  93 + // 弹窗图标(不填显示默认图标,链接配置示例如: '/static/demo/ic_attention.png')
  94 + appUpdateIcon: ''
  95 +}
  96 +```
  97 +
  98 +### 第二步 使用方法
  99 +```
  100 +// App.vue页面
  101 +
  102 +// #ifdef APP-PLUS
  103 +import APPUpdate from '@/uni_modules/zhouWei-APPUpdate/js_sdk/appUpdate';
  104 +// #endif
  105 +
  106 +onLaunch: function(e) {
  107 + // #ifdef APP-PLUS
  108 + APPUpdate();
  109 + // #endif
  110 +}
  111 +```
  112 +
  113 +### 第三步 添加APP安装应用的权限
  114 +`manifest.json`文件里面`APP模块权限配置`的`Android打包权限配置`勾选以下权限
  115 +```
  116 +<uses-permission android:name=\"android.permission.INSTALL_PACKAGES\"/>
  117 +<uses-permission android:name=\"android.permission.REQUEST_INSTALL_PACKAGES\"/>
  118 +```
  119 +
  120 +### 修改弹窗的主题色或弹窗图标
  121 +`APPUpdate/index.js`里面上面`$mainColor`常量中定义主题颜色,`$iconUrl`常量中定义图标地址
  122 +
  123 +### 检查APP是否有新版本(一般在设置页面使用)
  124 +```
  125 +// #ifdef APP-PLUS
  126 +import APPUpdate, { getCurrentNo } from '@/uni_modules/zhouWei-APPUpdate/js_sdk/appUpdate';
  127 +// #endif
  128 +export default {
  129 + data() {
  130 + return {
  131 + version: "" // 版本号
  132 + };
  133 + },
  134 + //第一次加载
  135 + onLoad(e) {
  136 + // #ifdef APP-PLUS
  137 + getCurrentNo(res => {
  138 + // 进页面获取当前APP版本号(用于页面显示)
  139 + this.version = res.version;
  140 + });
  141 + // #endif
  142 + },
  143 + //方法
  144 + methods: {
  145 + // 检查APP是否有新版本
  146 + onAPPUpdate() {
  147 + // true 没有新版本的时候有提示,默认:false
  148 + APPUpdate(true);
  149 + }
  150 + }
  151 +}
  152 +```
\ No newline at end of file
... ...