Commit d5c243ca authored by Damon's avatar Damon

Merge branch 'fix-photo' into dev-1.5.0

parents 72eccfed ff83edde
......@@ -158,7 +158,7 @@ export default {
}
} else {
uni.showModal({
title: "登录失败",
title: "登录失败,请重试",
content: "未获取到code",
});
}
......
......@@ -11,7 +11,6 @@ export default {
const options = {
files: uploadTask, // 必填 临时文件路径 格式: [{path: "图片地址"}]
load: false, //(默认 true 说明:本接口是否提示加载动画)
maxSize: 300000, //(默认 无 说明:上传的文件最大字节数限制,默认不限制)
onEachUpdate: res => {
console.log("上传成功返回:",res);
},
......@@ -19,22 +18,29 @@ export default {
console.log("上传进度返回:",res);
}
}
const result = await uploader.qnFileUpload(options)
if (result && !result.statusCode) { // 匹配已上传完成的图片,更新缓存数据
let newTask = []
let delImg = []
uploadTask.forEach(v => {
if (result.includes(`/${v.key}`)) { // 删除已上传的图片
delImg.push(v.path)
} else { // 未上传的重新存储
newTask.push(v)
}
})
uploader.qnFileUpload(options).then(res => {
this.refreshTask(that, res)
}).catch(err => {
console.log("err", err)
if (err.errMsg.indexOf('fail file not found') !== -1) { // 在任务中删除不存在的图片
this.refreshTask(that, ['failErr'])
}
})
},
refreshTask(that, result) {
const uploadTask = that.uploadTask
let newTask = []
let delImg = []
uploadTask.forEach(v => {
if (result.includes(`/${v.key}`) || result.includes('failErr')) { // 删除已上传的图片
delImg.push(v.path)
} else { // 未上传的重新存储
newTask.push(v)
}
})
// uni.setStorageSync('delImg', delImg) // 已上传完的图片,会在启动系统的时候做一次清理
that.$u.vuex('uploadTask', newTask)
}
// uni.setStorageSync('delImg', delImg) // 已上传完的图片,会在启动系统的时候做一次清理
that.$u.vuex('uploadTask', newTask)
}
}
\ No newline at end of file
......@@ -21,13 +21,18 @@
<view class="bind-tips">{{ bindTips }}</view>
</view>
<u-gap height="480"></u-gap>
<button class="loginBtn" v-if="needAuth" lang="zh_CN" @tap="getUserProfile">
<text class="u-font-32 white">{{ loginTitle }}</text>
</button>
<button class="loginBtn" v-else open-type="getPhoneNumber" throttle-time="1000"
@getphonenumber="signupLogin">
<text class="u-font-32 white">{{ bindTitle }}</text>
</button>
<view v-if="needAuth" @click.capture="loadLogin">
<button class="loginBtn" lang="zh_CN"
@tap="getUserProfile">
<text class="u-font-32 white">{{ loginTitle }}</text>
</button>
</view>
<view @click.capture="getCode" v-else>
<button class="loginBtn" open-type="getPhoneNumber"
throttle-time="1000" @getphonenumber="signupLogin">
<text class="u-font-32 white">{{ bindTitle }}</text>
</button>
</view>
</view>
</view>
</template>
......@@ -64,9 +69,14 @@ export default {
if (this.vuex_auth_user && Object.keys(this.vuex_auth_user).length) {
this.needAuth = false
}
this.getCode()
},
methods: {
loadLogin() {
uni.showLoading({
title: '加载中..',
mask: true
});
},
qnFile(src) {
return process.uniEnv.qn_base_url + src
},
......@@ -97,6 +107,7 @@ export default {
}
},
fail: function (res) {
uni.hideLoading()
uni.showModal({
title: '授权失败',
content: '请允许获取用户信息的授权',
......@@ -105,6 +116,7 @@ export default {
}
})
} else {
uni.hideLoading()
// 可能由于账号配置,或者其他原因导致无法调起微信用户授权
uni.showModal({
title: '授权失败',
......@@ -138,7 +150,12 @@ export default {
that.setLoginStatus()
})
},
inGetAuth() {
uni.showLoading({
title: '授权中..',
mask: true
});
},
signupLogin(e) {
var that = this
if(e && e.detail) {
......@@ -156,20 +173,24 @@ export default {
iv: e.detail.iv,
}
if (that.code) {
that.inGetAuth()
uni.checkSession({
success () {
//session_key 未过期,并且在本生命周期一直有效
params.code = that.code
that.inGetAuth()
login.signup(params).then(res => {
uni.hideLoading()
that.inGetAuth()
if (res) {
login.setUserData(res.data, that)
app.track('signup_login', {mobile: res.data.mobile});
app.profileSet(that)
app.profileAppend(that)
app.getBaseInfo(that)
uni.hideLoading()
that.goBackPage()
} else {
uni.hideLoading()
uni.showToast({
title: '授权失败,请重新授权',
icon: 'none'
......@@ -190,13 +211,15 @@ export default {
that.toLogin(params)
}
} else {
uni.hideLoading()
uni.showModal({
title: '提示',
showCancel: false,
content: e.detail.errMsg
content: '用户取消授权'
});
}
} else {
uni.hideLoading()
uni.showModal({
title: '提示',
showCancel: false,
......@@ -209,7 +232,6 @@ export default {
params.code = res.code
return login.signup(params);
}).then(res => {
uni.hideLoading()
if (res) {
login.setUserData(res.data, this)
app.track('signup_login', {mobile: res.data.mobile});
......@@ -218,6 +240,7 @@ export default {
app.getBaseInfo(this)
this.goBackPage()
} else {
uni.hideLoading()
uni.showToast({
title: '授权失败,请重新授权',
icon: 'none'
......@@ -361,6 +384,20 @@ export default {
justify-content: center;
}
.disable {
background-color: #2272FF !important;
font-size: 32rpx;
font-weight: 600;
color: #FFFFFF !important;
line-height: 104px;
width: 600rpx;
height: 104rpx;
border-radius: 52rpx;
display: flex;
align-items: center;
justify-content: center;
}
.cancelView {
width: 100%;
margin-top: 30rpx;
......
......@@ -1154,7 +1154,7 @@ export default {
let options = {
sourceType: ['album'], //['album', 'camera']
count: 3,
sizeType: ['compressed'],
sizeType: ['original'],
}
const value = await this.chooseImg(options)
self.$refs[
......
......@@ -15,7 +15,7 @@ function appLogin() {
fail() {
uni.hideLoading();
uni.showModal({
content: '小程序登录失败',
content: '小程序登录失败,请重试',
showCancel: false
});
reject();
......@@ -57,7 +57,7 @@ function signup(data) {
} else {
console.log(res.message)
uni.showModal({
content: '登录失败',
content: '登录失败,请重试',
showCancel: false
});
reject(res);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment