|
@@ -56,11 +56,21 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
+ <view v-if="showGetwxinfo" class="wxinfo">
|
|
|
+ <view class='getwxinput'>
|
|
|
+ <input type='nickname' name='nickname' :value='userInfo.nickname' @blur="onchangenickname" placeholder="点击获取微信昵称" />
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <button type="balanced" open-type="chooseAvatar" @chooseavatar="onChooseavatar">
|
|
|
+ 点击获取头像
|
|
|
+ </button>
|
|
|
+
|
|
|
+ </view>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import {myInfo} from '@/http/api/common.js'
|
|
|
+import {myInfo,modifyInfo} from '@/http/api/common.js'
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
@@ -71,8 +81,13 @@ export default {
|
|
|
qm:'无',
|
|
|
orderCount:'0',
|
|
|
isVendor:'0',
|
|
|
+ cartCount:'0',
|
|
|
img:'https://cdn.uviewui.com/uview/album/1.jpg',
|
|
|
},
|
|
|
+ userInfo:{
|
|
|
+ nickname:'',
|
|
|
+ avatar:''
|
|
|
+ },
|
|
|
list:[
|
|
|
{
|
|
|
id:1,
|
|
@@ -111,7 +126,7 @@ export default {
|
|
|
id:2,
|
|
|
url:'/static/myinfo/icomx_gysrz.png',
|
|
|
name:'供应商入驻',
|
|
|
- linkto:'/supplierPagespages/supplier/SupplierEntryForm'
|
|
|
+ linkto:'/supplierPages/pages/supplier/SupplierEntryForm'
|
|
|
},
|
|
|
{
|
|
|
id:3,
|
|
@@ -142,7 +157,8 @@ export default {
|
|
|
// url:'/static/myinfo/iconx_xitongg.png',
|
|
|
// name:'设置'
|
|
|
// },
|
|
|
- ]
|
|
|
+ ],
|
|
|
+ showGetwxinfo:false,
|
|
|
}
|
|
|
},
|
|
|
onShow() {
|
|
@@ -154,14 +170,70 @@ export default {
|
|
|
methods: {
|
|
|
async getmyInfo(){
|
|
|
let res = await myInfo()
|
|
|
+ console.log(res?.data?.data?.image);
|
|
|
+ if (!res.data.data.image || res.data.data.image == '') {
|
|
|
+ this.showGetwxinfo = true
|
|
|
+ return
|
|
|
+ }else{
|
|
|
+ this.showGetwxinfo = false
|
|
|
+ }
|
|
|
if (res.data.code == 200) {
|
|
|
this.myinfo.name = res.data.data.nickName
|
|
|
this.myinfo.img = res.data.data.image
|
|
|
this.myinfo.orderCount = res.data.data?.orderCount || 0
|
|
|
this.myinfo.isVendor= res.data.data?.isVendor || 0
|
|
|
+ this.myinfo.cartCount = res.data.data?.cartCount || 0
|
|
|
+
|
|
|
+ uni.setStorageSync('shoppingCartTotal',this.myinfo.cartCount)
|
|
|
+ if (this.myinfo.cartCount != 0) {
|
|
|
+ uni.setTabBarBadge({
|
|
|
+ index: 3,
|
|
|
+ text: this.myinfo.cartCount
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ uni.hideTabBarRedDot({
|
|
|
+ index: 3,
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|
|
|
},
|
|
|
+ onchangenickname(e){
|
|
|
+ this.userInfo.nickname = e.detail.value
|
|
|
+ },
|
|
|
+ async onChooseavatar(e) {
|
|
|
+
|
|
|
+ let avatarUrl = 'data:image/jpeg;base64,' + uni.getFileSystemManager().readFileSync(e.detail.avatarUrl,'base64')
|
|
|
+
|
|
|
+ this.userInfo.avatar = avatarUrl
|
|
|
+ let res = await modifyInfo({
|
|
|
+ nickname:this.userInfo.nickname,
|
|
|
+ images:this.userInfo.avatar
|
|
|
+ })
|
|
|
+ if (res.data.code == 200) {
|
|
|
+ this.getmyInfo()
|
|
|
+ }
|
|
|
+ this.showGetwxinfo=false
|
|
|
+ },
|
|
|
+ uploadFilePromise(file) {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ let a = uni.uploadFile({
|
|
|
+ url: env.BASEURL + '/open/upload/uploadFile', // 仅为示例,非真实的接口地址
|
|
|
+ filePath: file.url,
|
|
|
+ name: 'file',
|
|
|
+ success: (res) => {
|
|
|
+ const fileData = JSON.parse(res.data)
|
|
|
+ if (fileData.code == 500) {
|
|
|
+ resolve('')
|
|
|
+ }else{
|
|
|
+ const fileData = JSON.parse(res.data)
|
|
|
+ resolve(fileData.data.fileUrl)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ })
|
|
|
+ },
|
|
|
tologin(){
|
|
|
if(uni.getStorageSync('AppAuthorization')){
|
|
|
//登录
|
|
@@ -306,4 +378,24 @@ export default {
|
|
|
height: 100rpx;
|
|
|
justify-content: space-between;
|
|
|
}
|
|
|
+.getwxinput{
|
|
|
+ text-align: center;
|
|
|
+ margin: 20rpx 0;
|
|
|
+}
|
|
|
+.wxinfo{
|
|
|
+ position: fixed;
|
|
|
+ z-index: 10000;
|
|
|
+ top: 30vh;
|
|
|
+ width: 600rpx;
|
|
|
+ height: 330rpx;
|
|
|
+ left: 55rpx;
|
|
|
+ background: #e7e7e7;
|
|
|
+ border-radius: 10rpx;
|
|
|
+ padding: 20rpx;
|
|
|
+
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+}
|
|
|
</style>
|