Merge pull request '解决体验版弹出登录框' (#65) from dengjie into dev

Reviewed-on: http://git.hchyun.com/feashow/pupil/pulls/65
This commit is contained in:
odjbin
2023-01-28 14:36:24 +00:00
14 changed files with 213 additions and 83 deletions

View File

@@ -77,7 +77,6 @@
methods: {
//获取历史记录
getHistoryOrCollection() {
console.log(uni.getStorageSync('token'));
this.$apiServe.getHistoryOrCollection(this.type).then(res => {
let data = res.data.data
for (const item of data) {
@@ -156,6 +155,5 @@
font-weight: 400;
color: #FFFFFF;
line-height: 33px;
}
</style>

View File

@@ -1,6 +1,7 @@
<template>
<view>
<myForm ref="nameAndphone"></myForm>
<view style="height: 168rpx;"></view>
<u-button type="success" text="确定" color="#0EBB5B" @click="handleSureClick()"></u-button>
<u-modal :show="showM" closeOnClickOverlay="false" confirmText="确定" @confirm="confirm">
<rich-text :nodes="content"></rich-text>
@@ -30,9 +31,7 @@
}
},
onLoad() {
this.getIdeasAndNeeds()
if (!uni.getStorageSync('token') || uni.getStorageSync('token').length === 0) {
console.log(uni.getStorageSync('token'))
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
this.isLoad = false
// uni.navigateTo({
// url: '../../pages/my/login/login'
@@ -51,7 +50,7 @@
companyName: name,
companyPhone: phone
}).then(res => {
// console.log('绑定公司', res.data);
console.log('绑定公司', res.data);
if (res.data.code == 20003) {
this.showM = true
} else if (res.data.code == 20005) {
@@ -66,8 +65,7 @@
// })
},
reOnLoad() {
console.log('----------------true')
if (!uni.getStorageSync('token') || uni.getStorageSync('token').length === 0) {
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
this.$toast.warn('登录失败请重试')
this.isLoad = false
// uni.navigateTo({
@@ -78,7 +76,6 @@
this.isLoad = true
},
failToLoad() {
console.log('----------------false')
this.$toast.warn('登录失败请重试')
}
@@ -92,7 +89,6 @@
height: 86rpx !important;
background: #0EBB5B;
border-radius: 20rpx !important;
margin-top: 168rpx;
}
.u-modal__button-group__wrapper--hover {

View File

@@ -1,18 +1,52 @@
<template>
<view>
<productsBtn :type="1"></productsBtn>
<productsBtn :type="1" ref="browseHistory"></productsBtn>
<!-- <view style="margin:0 20rpx;">
<u-overlay :show="!isLoad">
<login @success="reOnLoad()" @fail="failToLoad()"></login>
</u-overlay>
</view> -->
</view>
</template>
<script>
import login from 'pages/my/login/login'
export default {
components: {
login
},
data() {
return {
type: ''
type: '',
isLoad: true,
}
},
onLoad() {
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
this.isLoad = false
// uni.navigateTo({
// url: '../../pages/my/login/login'
// })
return
}
this.isLoad = true
},
methods: {
reOnLoad() {
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
this.$toast.warn('登录失败请重试')
this.isLoad = false
// uni.navigateTo({
// url: '../../pages/my/login/login'
// })
return
}
this.isLoad = true
this.$refs.browseHistory.getHistoryOrCollection()
},
failToLoad() {
this.$toast.warn('登录失败请重试')
}
}
}
</script>

View File

@@ -11,14 +11,23 @@
placeholderStyle="color: #CCCCCC;font-size: 24rpx;"></u--input>
</u-form-item>
</u--form>
<u-button type="success" text="确定" color="#0EBB5B"></u-button>
<view style="height: 230rpx;"></view>
<u-button type="success" text="确定" color="#0EBB5B" @click="handleSubmit()"></u-button>
</view>
<view style="margin:0 20rpx;">
<u-overlay :show="!isLoad">
<login @success="reOnLoad()" @fail="failToLoad()"></login>
</u-overlay>
</view>
</view>
</template>
<script>
import login from 'pages/my/login/login'
export default {
components: {
login
},
data() {
return {
avatar: 'https://cdn.uviewui.com/uview/album/2.jpg',
@@ -27,8 +36,19 @@
name: ''
},
},
isLoad: true,
}
},
onLoad() {
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
this.isLoad = false
// uni.navigateTo({
// url: '../../pages/my/login/login'
// })
return
}
this.isLoad = true
},
methods: {
//修改头像
changeAvatar() {
@@ -38,13 +58,14 @@
success: (res) => {
console.log(res.tempFilePaths[0]); //成功则返回图片的本地文件路径列表 tempFilePaths
this.avatar = res.tempFilePaths[0] //更新本地浏览头像图片
// this.update(res.tempFilePaths[0]) //上传图片
}
});
},
update(filePath) {
const _this = this
const token = uni.getStorageSync('token')
const token = uni.getStorageSync('loginToken')
const res = uni.uploadFile({
url: _this.action, //仅为示例,非真实的接口地址
filePath: filePath,
@@ -61,6 +82,32 @@
}
});
},
//提交头像和昵称
handleSubmit() {
this.$apiServe.updateUser({
nickname: this.model.userInfo.name,
avatar: this.avatar
}).then(res => {
console.log('修改头像昵称==', res);
}).finally(_ => {})
},
reOnLoad() {
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
this.$toast.warn('登录失败请重试')
this.isLoad = false
// uni.navigateTo({
// url: '../../pages/my/login/login'
// })
return
}
this.isLoad = true
},
failToLoad() {
// uni.navigateBack({
// url: '/pages/my/my'
// })
this.$toast.warn('登录失败请重试')
}
}
}
</script>
@@ -78,6 +125,5 @@
height: 86rpx !important;
background: #0EBB5B;
border-radius: 20rpx !important;
margin-top: 230rpx;
}
</style>

View File

@@ -13,16 +13,26 @@
<u-modal :show="showM" closeOnClickOverlay="false" confirmText="确定" @confirm="confirm">
<rich-text :nodes="content"></rich-text>
</u-modal>
<!-- <view style="margin:0 20rpx;">
<u-overlay :show="!isLoad">
<login @success="reOnLoad()" @fail="failToLoad()"></login>
</u-overlay>
</view> -->
</view>
</template>
<script>
import login from 'pages/my/login/login'
export default {
components: {
login
},
data() {
return {
name: '',
phone: '',
showM: false,
isLoad: true,
//会员中心的用户名旁边不显示edit图标
show: false,
content: `请保持手机畅通<br>
@@ -30,6 +40,16 @@
commitment: '承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置'
}
},
onLoad() {
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
this.isLoad = false
// uni.navigateTo({
// url: '../../pages/my/login/login'
// })
return
}
this.isLoad = true
},
methods: {
// 联系客服模态框
handleSureClick() {
@@ -55,6 +75,20 @@
// uni.switchTab({
// url: '/pages/my/my'
// })
},
reOnLoad() {
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
this.$toast.warn('登录失败请重试')
this.isLoad = false
// uni.navigateTo({
// url: '../../pages/my/login/login'
// })
return
}
this.isLoad = true
},
failToLoad() {
this.$toast.warn('登录失败请重试')
}
}
}

View File

@@ -1,16 +1,51 @@
<template>
<view>
<productsBtn :type="2"></productsBtn>
<!-- <view style="margin:0 20rpx;">
<u-overlay :show="!isLoad">
<login @success="reOnLoad()" @fail="failToLoad()"></login>
</u-overlay>
</view> -->
</view>
</template>
<script>
import login from 'pages/my/login/login'
export default {
components: {
login
},
data() {
return {
type: ''
type: '',
isLoad: true,
}
},
methods: {}
onLoad() {
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
this.isLoad = false
// uni.navigateTo({
// url: '../../pages/my/login/login'
// })
return
}
this.isLoad = true
},
methods: {
reOnLoad() {
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
this.$toast.warn('登录失败请重试')
this.isLoad = false
// uni.navigateTo({
// url: '../../pages/my/login/login'
// })
return
}
this.isLoad = true
},
failToLoad() {
this.$toast.warn('登录失败请重试')
}
}
}
</script>

View File

@@ -88,10 +88,8 @@
}
},
onLoad() {
console.log(uni.getStorageSync('token'));
this.getIdeasAndNeeds()
if (!uni.getStorageSync('token') || uni.getStorageSync('token').length === 0) {
console.log(uni.getStorageSync('token'))
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
this.isLoad = false
// uni.navigateTo({
// url: '../../pages/my/login/login'
@@ -103,9 +101,8 @@
methods: {
//获取创意发布
getIdeasAndNeeds() {
console.log('this.type', this.type);
this.$apiServe.getIdeasAndNeeds(this.type).then(res => {
console.log('获取创意发布&需求发布', res.data.data);
// console.log('获取创意发布&需求发布', res.data.data);
let data = res.data.data
for (const item of data) {
item.pub_time = dateFormatXwDetail(item.pub_time)
@@ -127,7 +124,7 @@
//切换需求发布和创意发布
tabChange(data) {
this.tabCurrent = data.index
console.log('data.index', data.index);
// console.log('data.index', data.index);
if (data.index == 0) {
this.type = 1
} else if (data.index == 1) {
@@ -151,7 +148,7 @@
success: function(res) {
if (res.confirm) {
that.$apiServe.deleteIdeasAndNeeds(item.id).then(res => {
console.log('删除发布', res);
// console.log('删除发布', res);
if (res.data.code == 1) {
that.$toast.warn('删除成功')
}
@@ -166,8 +163,7 @@
})
},
reOnLoad() {
console.log('----------------true')
if (!uni.getStorageSync('token') || uni.getStorageSync('token').length === 0) {
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
this.$toast.warn('登录失败请重试')
this.isLoad = false
// uni.navigateTo({
@@ -176,9 +172,9 @@
return
}
this.isLoad = true
this.getIdeasAndNeeds()
},
failToLoad() {
console.log('----------------false')
this.$toast.warn('登录失败请重试')
}
}

View File

@@ -51,8 +51,7 @@
this.id = option.id
this.getCertifiedCjDetail()
this.imgUrl = uni.getStorageSync('img_url')
if (!uni.getStorageSync('token') || uni.getStorageSync('token').length === 0) {
console.log(uni.getStorageSync('token'))
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
this.isLoad = false
// uni.navigateTo({
// url: '../../pages/my/login/login'
@@ -65,7 +64,7 @@
//获取认证厂家详情
getCertifiedCjDetail() {
this.$apiServe.getCertifiedCjDetail(this.id).then(res => {
console.log('认证厂家详情页', res.data)
// console.log('认证厂家详情页', res.data)
if (res.data.data) {
let data = res.data.data
data.images = data.images.split(';')
@@ -76,8 +75,7 @@
}).finally(_ => {})
},
reOnLoad() {
console.log('----------------true')
if (!uni.getStorageSync('token') || uni.getStorageSync('token').length === 0) {
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
this.$toast.warn('登录失败请重试')
this.isLoad = false
// uni.navigateTo({
@@ -86,9 +84,9 @@
return
}
this.isLoad = true
this.getCertifiedCjDetail()
},
failToLoad() {
console.log('----------------false')
this.$toast.warn('登录失败请重试')
}
}

View File

@@ -41,8 +41,7 @@
onLoad(option) {
this.id = option.id
this.getNewsDetail()
if (!uni.getStorageSync('token') || uni.getStorageSync('token').length === 0) {
console.log(uni.getStorageSync('token'))
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
this.isLoad = false
// uni.navigateTo({
// url: '../../pages/my/login/login'
@@ -66,8 +65,7 @@
}).finally(_ => {})
},
reOnLoad() {
console.log('----------------true')
if (!uni.getStorageSync('token') || uni.getStorageSync('token').length === 0) {
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
this.$toast.warn('登录失败请重试')
this.isLoad = false
// uni.navigateTo({
@@ -76,9 +74,9 @@
return
}
this.isLoad = true
this.getNewsDetail()
},
failToLoad() {
console.log('----------------false')
this.$toast.warn('登录失败请重试')
}
}

View File

@@ -87,8 +87,7 @@
this.id = option.id
this.getProductDetail()
this.imgUrl = uni.getStorageSync('img_url')
if (!uni.getStorageSync('token') || uni.getStorageSync('token').length === 0) {
console.log(uni.getStorageSync('token'))
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
this.isLoad = false
// uni.navigateTo({
// url: '../../pages/my/login/login'
@@ -100,9 +99,8 @@
methods: {
//获取详情信息
getProductDetail() {
console.log(this.id);
this.$apiServe.getProductDetail(this.id).then(res => {
console.log('产品详情页', res.data)
// console.log('产品详情页', res.data)
if (res.data.data.thumb) {
this.isThumb = true
}
@@ -121,7 +119,7 @@
//收藏按钮
starTap() {
this.$apiServe.collect(this.id).then(res => {
console.log('收藏成功', res.data)
// console.log('收藏成功', res.data)
if (res.data.code == 1) {
this.detailList.is_fav = 1
this.$toast.warn('收藏成功')
@@ -135,8 +133,7 @@
this.showHeart = !this.showHeart
},
reOnLoad() {
console.log('----------------true')
if (!uni.getStorageSync('token') || uni.getStorageSync('token').length === 0) {
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
this.$toast.warn('登录失败请重试')
this.isLoad = false
// uni.navigateTo({
@@ -145,9 +142,9 @@
return
}
this.isLoad = true
this.getProductDetail()
},
failToLoad() {
console.log('----------------false')
this.$toast.warn('登录失败请重试')
}
}
@@ -170,10 +167,8 @@
right: 77rpx;
z-index: 99;
}
}
.content {
padding: 20rpx;
background-color: #fff;

View File

@@ -155,8 +155,8 @@
},
onTabItemTap() {
console.log('----onTabItemTap')
if (!uni.getStorageSync('token') || uni.getStorageSync('token').length === 0) {
console.log(uni.getStorageSync('token'))
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
console.log(uni.getStorageSync('loginToken'))
this.isLoad = false
// uni.navigateTo({
// url: '../../pages/my/login/login'
@@ -164,7 +164,7 @@
return
}
this.isLoad = true
this.token = uni.getStorageSync('token')
this.token = uni.getStorageSync('loginToken')
this.getFormData()
this.fileList1 = []
this.needsPublishForm = {}
@@ -368,7 +368,8 @@
return false
}
this.needsPublishForm.type = Number(this.tabCurrent + 1)
this.needsPublishForm.pub_time = this.needsPublishForm.pub_time ? this.needsPublishForm.pub_time : new Date().getTime()
this.needsPublishForm.pub_time = this.needsPublishForm.pub_time ? this.needsPublishForm.pub_time :
new Date().getTime()
const temp = []
if (this.fileList1.length > 0) {
this.fileList1.map(item => {
@@ -392,12 +393,14 @@
...this.needsPublishForm
}
apiService.submitIdeasAndNeeds(data).then(res => {
this.$toast.success(res.data.msg)
this.$toast.warn('发布成功')
console.log('esf=', res);
// this.$toast.success(res.data.msg)
})
},
reOnLoad() {
console.log('----------------true')
if (!uni.getStorageSync('token') || uni.getStorageSync('token').length === 0) {
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
this.$toast.warn('登录失败请重试')
this.isLoad = false
// uni.navigateTo({
@@ -405,7 +408,7 @@
// })
return
}
this.token = uni.getStorageSync('token')
this.token = uni.getStorageSync('loginToken')
this.isLoad = true
this.getFormData()
},

View File

@@ -96,18 +96,8 @@
// code: code
// }).then(res => {
// var data = res.data.data
// console.log('登录code换取的信息', data);
// // uni.setStorageSync('token', data.token);
// // that.$toast.success('登录成功')
// // that.$emit('success')
// //登录完成后使用手机code换取手机号,调用/user/getMobileByMnp接口
// //接口详细链接 https://docs.apipost.cn/preview/468be606f65cae75/3f2f988ddf82dd8e
// // const codeData = {
// // code: e.detail.code
// // }
// // apiService.postMobileByMnp(codeData).then(res => {
// // console.log(res)
// // })
// // console.log('登录code换取的信息', data);
// uni.setStorageSync('token', data.token);
// })
// },
// })

View File

@@ -38,7 +38,7 @@
}).then(res => {
var data = res.data.data
// console.log('登录code换取的信息', data);
uni.setStorageSync('token', data.token);
uni.setStorageSync('loginToken', data.token);
that.$toast.success('登录成功')
that.$emit('success')
//登录完成后使用手机code换取手机号,调用/user/getMobileByMnp接口

View File

@@ -8,7 +8,7 @@ function isOutTime(res) {
})
}, 1000)
uni.removeStorageSync('userInfo')
uni.removeStorageSync('token')
uni.removeStorageSync('loginToken')
} else {
// uni.showToast(res.data.message);
}
@@ -18,7 +18,7 @@ const service = {
get(url, data) {
const header = {}
// header['Authorization'] = 'Bearer ' + uni.getStorageSync('token')
header['token'] = uni.getStorageSync('token')
header['token'] = uni.getStorageSync('loginToken')
header['content-type'] = 'application/json'
return new Promise((resolve, reject) => {
uni.request({
@@ -43,7 +43,7 @@ const service = {
},
post(url, data, isLogin) {
const header = {}
header['token'] = uni.getStorageSync('token')
header['token'] = uni.getStorageSync('loginToken')
header['content-type'] = 'application/json'
return new Promise((resolve, reject) => {
uni.request({
@@ -92,7 +92,7 @@ const service = {
},
put(url, data, isLogin) {
const header = {}
header['token'] = uni.getStorageSync('token')
header['token'] = uni.getStorageSync('loginToken')
header['content-type'] = 'application/json'
return new Promise((resolve, reject) => {
uni.request({
@@ -100,10 +100,10 @@ const service = {
url: serverHost + url,
header: header,
success: res => {
if (!res.data.flag) {
isOutTime(res)
reject(res)
}
// if (!res.data.flag) {
// isOutTime(res)
// reject(res)
// }
resolve(res)
},
data: data,
@@ -118,7 +118,7 @@ const service = {
},
putWithFormData(url, data, isLogin) {
const header = {}
header['token'] = uni.getStorageSync('token')
header['token'] = uni.getStorageSync('loginToken')
header['content-type'] = 'application/x-www-form-urlencoded'
return new Promise((resolve, reject) => {
uni.request({
@@ -144,7 +144,7 @@ const service = {
},
delete(url, data, isLogin) {
const header = {}
header['token'] = uni.getStorageSync('token')
header['token'] = uni.getStorageSync('loginToken')
header['content-type'] = 'application/json'
return new Promise((resolve, reject) => {
uni.request({
@@ -205,7 +205,7 @@ const toast = {
}
}
const apiService = {
uploadImgUrl: serverHost + `/upload/image/`,
uploadImgUrl: serverHost,
imgUrl: serverHost,
// login: data => {
// data = Object.assign(data || {}, {})
@@ -326,6 +326,13 @@ const apiService = {
resolve(service.get(url))
})
},
//修改个人信息
updateUser(data) {
const url = `/center/userupdate`
return new Promise((resolve, reject) => {
resolve(service.post(url, data))
})
},
// 获取首页分类Tag
getTags(data) {
const url = `/home/tags`