@10yun/cv-mobile-ui 0.5.24 → 0.5.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,33 +1,11 @@
1
1
  import HttpObj from '@/plugins/http.js';
2
- uni.request({
3
- url: 'https://uniapp.dcloud.io/update', // 检查更新的服务器地址
4
- data: {
5
- appid: (plus.runtime.appid || ''),
6
- version: (plus.runtime.version || ''),
7
- imei: (plus.device.imei || ''),
8
- },
9
- success: res => {
10
- if (res.statusCode == 200 && res.data.isUpdate) {
11
- let openUrl = plus.os.name === 'iOS' ? res.data.iOS : res.data.Android;
12
- // 提醒用户更新
13
- uni.showModal({
14
- title: '更新提示',
15
- content: res.data.note ? res.data.note : '是否选择更新',
16
- success: showResult => {
17
- if (showResult.confirm) {
18
- plus.runtime.openURL(openUrl);
19
- }
20
- }
21
- });
22
- }
23
- }
24
- });
25
- // APP检测更新 具体可以参考:https://ask.dcloud.net.cn/article/35667
26
- plus.runtime.getProperty(plus.runtime.appid, widgetInfo => {
27
-
2
+ function checkVersion(plus,widgetInfo){
28
3
  uni.request({
29
4
  url: 'https://uniapp.dcloud.io/update', // 检查更新的服务器地址
30
5
  data: {
6
+ appid: (plus.runtime.appid || ''),
7
+ version: (plus.runtime.version || ''),
8
+ imei: (plus.device.imei || ''),
31
9
  appid: widgetInfo.appid, //当前应用的APPID
32
10
  version: widgetInfo.version, // 当前应用的版本
33
11
  name: widgetInfo.name, // 当前应用的名称
@@ -35,27 +13,135 @@ plus.runtime.getProperty(plus.runtime.appid, widgetInfo => {
35
13
  os: plus.os.name // OS环境 ios / android
36
14
  },
37
15
  success: res => {
38
- if (res.code == 200) {
39
- uni.downloadFile({
40
- url: res.data.wgtUrl,
41
- success: (downloadResult) => {
42
- if (downloadResult.statusCode === 200) {
43
- plus.runtime.install(downloadResult.tempFilePath, {
44
- force: false
45
- }, (d) => {
46
- console.log('install success...');
47
- plus.runtime.restart();
48
- }, (e) => {
49
- console.error('install fail...');
50
- })
16
+ if (res.code == 200) {
17
+ if(res.data.version_update ='no_need'){
18
+ uni.showModal({
19
+ title: '提示',
20
+ content: '已是最新版本',
21
+ showCancel: false
22
+ });
23
+ }else{
24
+ if(res.data.version_update ='yes_need'){
25
+ showVersion(res.data);
51
26
  }
52
27
  }
28
+ }
29
+ }
30
+ });
31
+ }
32
+ function showVersion(apiData){
33
+
34
+
35
+ // 提醒用户更新
36
+ uni.showModal({
37
+ title: '更新提示',
38
+ title: '版本更新' + apiData.versionCode,
39
+ content: apiData.note ? apiData.note : '是否选择更新',
40
+ content: apiData.description,
41
+ confirmText: '更新',
42
+ showCancel: !res.forceUpdate,
43
+ success: showResult => {
44
+ if (showResult.confirm) {
45
+ downVersion(apiData);
46
+ } else {
47
+ //取消
48
+ }
49
+ }
50
+ });
51
+ }
52
+ function downVersion(){
53
+
54
+
55
+ if (plus.os.name.toLowerCase() == 'ios') {
56
+ // 跳转到下载页面
57
+ let upgradeUrl = apiData.url_ios;
58
+ plus.runtime.openURL(res.data.upgradeUrl);
59
+ } else {
60
+ // let upgradeUrl = apiData.url_android;
61
+ // plus.runtime.openURL(upgradeUrl);
62
+ var dtask = plus.downloader.createDownload(res.data.upgradeUrl, {}, function (d, status) {
63
+ uni.showToast({
64
+ title: '下载完成',
65
+ mask: false,
66
+ duration: 1000
67
+ });
68
+ // 下载完成
69
+ if (status == 200) {
70
+ plus.runtime.install(
71
+ plus.io.convertLocalFileSystemURL(d.filename),
72
+ {},
73
+ (e) => e,
74
+ function (error) {
75
+ uni.showToast({
76
+ title: '安装失败-01',
77
+ mask: false,
78
+ duration: 1500
79
+ });
80
+ }
81
+ );
82
+ } else {
83
+ uni.showToast({
84
+ title: '更新失败-02',
85
+ mask: false,
86
+ duration: 1500
87
+ });
88
+ }
89
+ });
90
+ try {
91
+ dtask.start(); // 开启下载的任务
92
+ var prg = 0;
93
+ var showLoading = plus.nativeUI.showWaiting('正在下载'); //创建一个showWaiting对象
94
+ dtask.addEventListener('statechanged', function (task, status) {
95
+ // 给下载任务设置一个监听 并根据状态 做操作
96
+ switch (task.state) {
97
+ case 1:
98
+ showLoading.setTitle('正在下载');
99
+ break;
100
+ case 2:
101
+ showLoading.setTitle('已连接到服务器');
102
+ break;
103
+ case 3:
104
+ prg = parseInt((parseFloat(task.downloadedSize) / parseFloat(task.totalSize)) * 100);
105
+ showLoading.setTitle(' 正在下载' + prg + '% ');
106
+ break;
107
+ case 4:
108
+ plus.nativeUI.closeWaiting();
109
+ //下载完成
110
+ break;
111
+ }
112
+ });
113
+ } catch (err) {
114
+ plus.nativeUI.closeWaiting();
115
+ uni.showToast({
116
+ title: '更新失败-03',
117
+ mask: false,
118
+ duration: 1500
53
119
  });
54
120
  }
55
121
  }
56
- });
57
-
122
+ }
123
+ function downloadVersion(){
124
+ uni.downloadFile({
125
+ url: res.data.wgtUrl,
126
+ success: (downloadResult) => {
127
+ if (downloadResult.statusCode === 200) {
128
+ plus.runtime.install(downloadResult.tempFilePath, {
129
+ force: false
130
+ }, (d) => {
131
+ console.log('install success...');
132
+ plus.runtime.restart();
133
+ }, (e) => {
134
+ console.error('install fail...');
135
+ })
136
+ }
137
+ }
138
+ });
139
+ }
58
140
 
141
+ // APP检测更新 具体可以参考:https://ask.dcloud.net.cn/article/35667
142
+ plus.runtime.getProperty(plus.runtime.appid, widgetInfo => {
143
+ checkVersion(plus,widgetInfo);
144
+ });
59
145
 
60
146
  var UniUpgradeClass = function{
61
147
  // console.log('App Launch')
@@ -107,4 +193,102 @@ var UniUpgradeClass = function{
107
193
  })
108
194
  });
109
195
  }
110
- }
196
+ }
197
+ function showPlusVersion() {
198
+ // 跟后台传过来的版本号比对,如果版本号不一致
199
+ plus.nativeUI.confirm(
200
+ '检测到有新版本,是否更新',
201
+ function (e) {
202
+ /**
203
+ * 如果是苹果手机
204
+ */
205
+ if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
206
+ /**
207
+ * 如果选择更新
208
+ */
209
+ if (e.index == 0) {
210
+ window.location.href = 'itms-services://?action=download-manifest&url=https://ios.17rua.top/static/ios/x5.plist';
211
+ //不经过苹果商店下载(不懂得看我的另一篇文章)
212
+ plus.nativeUI.showWaiting('正在下载...');
213
+ }
214
+ } else {
215
+ if (e.index == 0) {
216
+ that.downWgt(res.data.url); //下载文件
217
+ } else {
218
+ plus.runtime.quit(); //安卓控制不更新退出应用
219
+ }
220
+ }
221
+ },
222
+ '',
223
+ ['立即更新', '以后再说']
224
+ );
225
+ }
226
+
227
+ function versionCheckUpdate() {
228
+ var that = this;
229
+ HttpObj.post('/version/checkUpdate', {
230
+ version: that.wgtVer
231
+ })
232
+ .then((res) => {
233
+ if (res.data.code == 0) {
234
+ showPlusVersion();
235
+ // 检验过一次版本就加入缓存,不在检测
236
+ sessionStorage.setItem('kbj_banben', true);
237
+ } else {
238
+ alert('获取数据失败');
239
+ }
240
+ })
241
+ .catch(function (error) {
242
+ alert('请检查网络连接');
243
+ });
244
+ }
245
+ let xx = {
246
+ //检测当前版本号
247
+ dqbanben: function () {
248
+ var that = this;
249
+ //在页面中初始化plus插件
250
+ mui.init();
251
+ mui.plusReady(function () {
252
+ // 获取本地应用资源版本号
253
+ that.wgtVer = plus.runtime.version;
254
+ that.checkUpdate();
255
+ });
256
+ },
257
+ //检查更新
258
+ checkUpdate: function () {},
259
+ //下载资源包
260
+ downWgt: function (wgtUrl) {
261
+ var that = this;
262
+ var task = plus.downloader.createDownload(wgtUrl, {}, function (download, status) {
263
+ //安装到手机的目录
264
+ if (status == 200) {
265
+ plus.runtime.install(download.filename); // 安装下载的apk文件
266
+ } else {
267
+ mui.toast('下载更新失败!');
268
+ plus.nativeUI.closeWaiting();
269
+ }
270
+ });
271
+ //监听下载
272
+ task.addEventListener('statechanged', function (download, status) {
273
+ switch (download.state) {
274
+ case 2:
275
+ plus.nativeUI.showWaiting('正在下载...');
276
+ break;
277
+ case 3:
278
+ //进度条百分比 totalSize为总量,baifen为当前下载的百分比
279
+ if (that.totalSize == 0) {
280
+ that.totalSize = parseInt(download.totalSize);
281
+ }
282
+ if (parseInt((download.downloadedSize / that.totalSize) * 100) != that.baifen) {
283
+ that.baifen = parseInt((download.downloadedSize / that.totalSize) * 100);
284
+ }
285
+ break;
286
+ case 4:
287
+ mui.toast('下载完成');
288
+ plus.nativeUI.closeWaiting();
289
+ break;
290
+ }
291
+ });
292
+ task.start();
293
+ }
294
+ };
@@ -1,5 +1,4 @@
1
1
  /* 基础图标库 */
2
- // const iconsFiles = import.meta.globEager('./iconfont/*-icons.js');
3
2
  const iconsFiles = import.meta.glob('./iconfont/*-icons.js', { eager: true });
4
3
  console.log('---iconsFiles--', iconsFiles);
5
4
  const modules = {};
@@ -84,7 +84,7 @@ export default {
84
84
  }
85
85
  }
86
86
 
87
- // this.swiperChange(option.order_state);
87
+ // this.swiperChange(option.xxxx);
88
88
  },
89
89
  methods: {
90
90
  animationfinish({ detail: { current } }) {
package/plugins/jumps.js DELETED
@@ -1,163 +0,0 @@
1
- function doJumpUrl(jumpType) {
2
- let jumpUrl = '';
3
- if (typeof jumpType == 'string') {
4
- jumpUrl = jumpType;
5
- } else if (typeof jumpType === 'object') {
6
- jumpUrl = jumpType.currentTarget.dataset.url;
7
- }
8
- jumpUrl = jumpUrl || '';
9
- if (jumpUrl != '') {
10
- // 是否/开头,如果不是,追加/开头
11
- if (!jumpUrl.match(new RegExp('^/pages/.*$'))) {
12
- jumpUrl = '/pages/' + jumpUrl;
13
- }
14
- jumpUrl = jumpUrl.replace(/\/\//g, '/');
15
- }
16
- // console.log(encodeURI(e.currentTarget.dataset.url));
17
- return jumpUrl;
18
- }
19
- function doUrlParam(url, query = {}, isSequence = true) {
20
- if (!query) return url;
21
- let joiner = url.match(/\?/) ? '&' : '?';
22
- let queryArr = [];
23
- let queryStr = '';
24
- if (Object.keys(query).length > 0) {
25
- for (const key in query) {
26
- queryArr.push(key + '=' + query[key]);
27
- }
28
- queryStr = queryArr.join('&');
29
- return url + joiner + queryStr;
30
- }
31
- return url;
32
- }
33
-
34
- class JumpsClass {
35
- constructor(options = {}) {
36
- this.page_my = options.page_my || '';
37
- this.page_home = options.page_home || '';
38
- this.page_login = options.page_login;
39
- this.page_xieyi = options.page_xieyi;
40
- this.storeHandle = options.storeHandle;
41
- }
42
- jumpsPage = (url, urlPm, time) => {
43
- url = url || '';
44
- let jumpUrl = doJumpUrl(url);
45
- if (jumpUrl == '') {
46
- uni.showToast({
47
- title: '即将上线,敬请期待!',
48
- icon: 'none',
49
- duration: 1500
50
- });
51
- return;
52
- }
53
- urlPm = urlPm || {};
54
- jumpUrl = doUrlParam(jumpUrl, urlPm);
55
- time = time || 1;
56
- let timeFunc = setTimeout(() => {
57
- // clearInterval(time);
58
- uni.navigateTo({
59
- url: jumpUrl,
60
- fail: function () {
61
- uni.switchTab({
62
- url: jumpUrl,
63
- fail: function () {}
64
- });
65
- }
66
- });
67
- }, time);
68
- };
69
-
70
- jumpsAuth = (jumpUrl, urlPm, time) => {
71
- jumpUrl = jumpUrl || '';
72
- if (jumpUrl == '') {
73
- uni.showToast({
74
- title: '即将上线,敬请期待!',
75
- icon: 'none',
76
- duration: 1500
77
- });
78
- return;
79
- } else {
80
- console.log('debug===是否登录,has_login:', this.storeHandle.state.storeUser.has_login);
81
- if (!this.storeHandle.state.storeUser.has_login) {
82
- this.jumpsLogin();
83
- } else {
84
- this.jumpsPage(jumpUrl, urlPm, time);
85
- }
86
- }
87
- };
88
- jumpsLogin = () => {
89
- uni.showModal({
90
- content: '您还未登录,请前往登录',
91
- showCancel: false,
92
- success: (res) => {
93
- if (res.confirm) {
94
- uni.navigateTo({
95
- url: this.page_login
96
- });
97
- }
98
- }
99
- });
100
- };
101
- // 跳转到用户页
102
- jumpsMy = (time) => {
103
- this.jumpsPage(this.page_my, time);
104
- };
105
- // 跳转到主页
106
- jumpsHome = (time) => {
107
- this.jumpsPage(this.page_home, time);
108
- };
109
- /**
110
- * 跳转协议
111
- * @param {*} name
112
- */
113
- jumpsXieyi = (name) => {
114
- this.jumpsPage(this.page_xieyi, {
115
- // 'no': 'XY003',
116
- title: name
117
- });
118
- };
119
- // 上一个页面
120
- jumpsPre = () => {
121
- let pages = getCurrentPages();
122
- let prePage = pages[pages.length - 2];
123
- // #ifdef H5
124
- return prePage;
125
- // #endif
126
- return prePage.$vm;
127
- };
128
- /**
129
- * 返回页面
130
- * @param {*} name
131
- */
132
- jumpsBack = (jumpUrl, time) => {
133
- time = time || 1000;
134
- let pages = getCurrentPages(); //页面栈
135
- let prePage = pages[pages.length - 2]; //上一页
136
- prePage.$vm.reFresh = Math.random(); //触发上一页监听器
137
- setTimeout(() => {
138
- uni.navigateBack(); //返回上一页
139
- }, time);
140
- };
141
- }
142
- export const useBindPlugin = (bindInstance, options) => {
143
- const jumpsObj = new JumpsClass(options);
144
-
145
- bindInstance.cv__jumpPage = jumpsObj.jumpsPage;
146
- bindInstance.cv__jumpAuth = jumpsObj.jumpsAuth;
147
- bindInstance.cv__jumpHome = jumpsObj.jumpsHome;
148
- bindInstance.cv__jumpMy = jumpsObj.jumpsMy;
149
- bindInstance.cv__jumpLogin = jumpsObj.jumpsLogin;
150
- bindInstance.cv__jumpXieyi = jumpsObj.jumpsXieyi;
151
- bindInstance.cv__jumpPre = jumpsObj.jumpsPre;
152
- bindInstance.cv__jumpBack = jumpsObj.jumpsBack;
153
-
154
- uni.cv__jumpPage = jumpsObj.jumpsPage;
155
- uni.cv__jumpAuth = jumpsObj.jumpsAuth;
156
- uni.cv__jumpHome = jumpsObj.jumpsHome;
157
- uni.cv__jumpMy = jumpsObj.jumpsMy;
158
- uni.cv__jumpLogin = jumpsObj.jumpsLogin;
159
- uni.cv__jumpXieyi = jumpsObj.jumpsXieyi;
160
- uni.cv__jumpPre = jumpsObj.jumpsPre;
161
- uni.cv__jumpBack = jumpsObj.jumpsBack;
162
- };
163
- export default JumpsClass;