-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathuni-app.txt
258 lines (238 loc) · 5.82 KB
/
uni-app.txt
1
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
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
254
255
256
257
258
https://uniapp.dcloud.io/api/README
https://uniapp.dcloud.io/component/README
https://github.com/aben1188/awesome-uni-app
uni.switchTab({url:"../fenlei/index"})
uni.navigateTo({url:"../../pages/login/index"})
uni.redirectTo({url:"../index/index"})
uni.setStorageSync("token", v);
uni.getStorageSync("token");
uni.clearStorage()
uni.getStorage({
key: 'accessToken',
success(res) { },
fail() { }
})
uni.setStorage({
key: 'accessToken',
data: data,
success() { }
})
this.$router.go(-1);
uni.navigateBack({ delta:1 })
uni.request({
url: url,
method: "GET",
data: data,
success: function(rs){ },
complete: function() { uni.hideLoading(); }
})
uni.request({
url: url,
data: data,
method: "POST",
header: { "content-type": "application/x-www-form-urlencoded" },
success: function(rs) { },
complete: function() { uni.hideLoading(); },
fail(res) {}
})
uni.request({
url,
method,
data,
success(res) { },
fail(res) { }
})
uni.showModal({
title: '请登录',
content: '请登录后继续操作',
confirmText: '去登录',
confirmColor: '#3296FA',
showCancel: false,
success: function(res) {
if (res.confirm) {
return false;
}
}
})
uni.showModal({
title: '未绑定手机,无法找回密码',
confirmText: '知道了',
content: '请联系客服处理,客服email: [email protected]',
success: function(res) {}
});
uni.showLoading({ title: '登录中', icon: 'none' })
uni.hideLoading()
uni.login({
provider: 'weixin',
success: function(res) {
}
}
uni.showToast({
icon: 'none',
title: '账号长度必须为5-12个字符'
});
plus.screen.lockOrientation('portrait-primary');
plus.runtime.openURL(openUrl);
plus.zip.compressImage({
src: _image,//原始图片的路径
dst: _image,//压缩转换目标图片的路径(为了省事这里使用原路径)
overwrite: true,//使用原文件名并覆盖,如果想将原文件保留,并和压缩后图片同时上传,需要改为false,并修改dst
quality: 100,//1-100,压缩后质量,越低图片占用空间越小,越模糊
width: max_width+'px',//这里先写死800;height默认为auto,即根据width与源图宽的缩放比例计算
},
(res) => {
},
(e) => {
}
)
uni.getImageInfo({
src: _image,
success: res => {
resolve(res);
}
})
uni.getProvider({
service: 'push',
success: function(res) {
if (~res.provider.indexOf('igexin')) {
uni.subscribePush({
provider: 'igexin',
success: function(res) {}
});
}
}
});
uni.onPush({
provider: 'igexin',
callback: function(data) {
var title = '';
var jsondata = JSON.parse(data.data);
for (var a in jsondata) {
title += a + '=' + jsondata[a];
}
uni.showModal({
title: '提示',
content: title,
success: function(res) {
if (res.confirm) {
} else if (res.cancel) {
}
}
});
}
});
uni.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['album'],
success: function(res) {
const tempFilePaths = res.tempFilePaths;
const uploadTask = uni.uploadFile({
url: url,
filePath: tempFilePaths[0],
name: 'file',
formData: {},
success: function(res) {}
}).onProgressUpdate(function(res) {
_self.percent = res.progress;
console.log('上传进度' + res.progress);
console.log('已经上传的数据长度' + res.totalBytesSent);
console.log('预期需要上传的数据总长度' + res.totalBytesExpectedToSend);
});
}
});
this.$store.dispatch('getUserInfo',{accessToken:this.inputValue})
var that = this;
var query = uni.createSelectorQuery();
query.selectAll('.m-item').boundingClientRect();
query.select('#scrollview').boundingClientRect();
query.exec(function (res) {
that.style.mitemHeight = 0;
res[0].forEach(function (rect) {
that.style.mitemHeight = that.style.mitemHeight + rect.height + 20;});
if (that.style.mitemHeight > that.style.contentViewHeight) {
that.scrollTop = that.style.mitemHeight - that.style.contentViewHeight;
}
});
uni.showActionSheet({
itemList:['保存图片到相册'],
success: () => {
plus.gallery.save('https://img.cdn.aliyun.dcloud.net.cn/guide/uniapp/app_download.png', function() {
uni.showToast({
title:'保存成功',
icon:'none'
})
}, function() {
uni.showToast({
title:'保存失败,请重试!',
icon:'none'
})
});
}
})
uni.getProvider({
service: 'share',
success: (e) => {
let data = [];
for (let i = 0; i < e.provider.length; i++) {
switch (e.provider[i]) {
case 'weixin':
data.push({
name: '分享到微信好友',
id: 'weixin'
})
data.push({
name: '分享到微信朋友圈',
id: 'weixin',
type: 'WXSenceTimeline'
})
break;
case 'qq':
data.push({
name: '分享到QQ',
id: 'qq'
})
break;
default:
break;
}
}
this.providerList = data;
},
fail: (e) => {
console.log('获取登录通道失败'+ JSON.stringify(e));
}
});
uni.share({
provider: this.providerList[res.tapIndex].id,
scene: this.providerList[res.tapIndex].type && this.providerList[res.tapIndex].type === 'WXSenceTimeline' ? 'WXSenceTimeline' : "WXSceneSession",
type: 0,
title:'欢迎体验uni-app',
summary: 'uni-app 是一个使用 Vue.js 开发跨平台应用的前端框架',
imageUrl:'https://img-cdn-qiniu.dcloud.net.cn/uploads/nav_menu/8.jpg',
href: "https://m3w.cn/uniapp",
success: (res) => {
console.log("success:" + JSON.stringify(res));
},
fail: (e) => {
uni.showModal({
content: e.errMsg,
showCancel:false
})
}
});
uni.getLocation({
type: 'wgs84',
success: function (res) {
console.log('当前位置的经度:' + res.longitude);
console.log('当前位置的纬度:' + res.latitude);
}
});
uni.chooseLocation({
success: function (res) {
console.log('位置名称:' + res.name);
console.log('详细地址:' + res.address);
console.log('纬度:' + res.latitude);
console.log('经度:' + res.longitude);
}
});