增加用户图标编辑功能
This commit is contained in:
parent
e73c80c1a9
commit
5031aed2cb
4
app.json
4
app.json
@ -34,7 +34,9 @@
|
||||
"pages/home/chemical/chemical",
|
||||
"pages/additive/list/additive-list",
|
||||
"pages/standard/list/index",
|
||||
"pages/user/index"
|
||||
"pages/user/index",
|
||||
"pages/user/session-list/index",
|
||||
"pages/user/edit/index"
|
||||
],
|
||||
"tabBar": {
|
||||
"custom": true,
|
||||
|
||||
BIN
images/check.png
Normal file
BIN
images/check.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 42 KiB |
BIN
images/history.png
Normal file
BIN
images/history.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.7 KiB |
BIN
images/question.png
Normal file
BIN
images/question.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.2 KiB |
BIN
images/use_btn.jpg
Normal file
BIN
images/use_btn.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 5.3 KiB |
@ -1,5 +1,5 @@
|
||||
const images = [{
|
||||
img: '/images/use_bi.jpg',
|
||||
img: '/images/use_btn.jpg',
|
||||
text: '1',
|
||||
},
|
||||
{
|
||||
|
||||
@ -14,7 +14,7 @@ Page({
|
||||
addtiveList: [],
|
||||
page: {
|
||||
num: 1,
|
||||
size: 20,
|
||||
size: 10,
|
||||
total: 0
|
||||
}
|
||||
},
|
||||
@ -26,7 +26,7 @@ Page({
|
||||
this.getAddtiveList();
|
||||
},
|
||||
|
||||
getAddtiveList() {
|
||||
getAddtiveList(append) {
|
||||
console.log(this.data.searchValue);
|
||||
const params = {
|
||||
pageNumber: this.data.page.num,
|
||||
@ -36,10 +36,17 @@ Page({
|
||||
params['search'] = this.data.searchValue
|
||||
}
|
||||
sessionAdditiveList(params).then(respose => {
|
||||
this.setData({
|
||||
addtiveList: respose.content.contentList,
|
||||
"page.total": respose.content.total
|
||||
})
|
||||
if (append) {
|
||||
this.setData({
|
||||
addtiveList: this.data.addtiveList.concat(respose.content.contentList),
|
||||
"page.total": respose.content.total
|
||||
})
|
||||
} else {
|
||||
this.setData({
|
||||
addtiveList: respose.content.contentList,
|
||||
"page.total": respose.content.total
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
@ -99,7 +106,11 @@ Page({
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
const num = this.data.page.num;
|
||||
this.setData({
|
||||
"page.num": num + 1
|
||||
})
|
||||
this.getAddtiveList(true);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@ -12,15 +12,15 @@
|
||||
<text style="width: 50%;">cns: {{additiveData.cns ? additiveData.cns : '-'}}</text>
|
||||
<text style="width: 50%;">ins: {{additiveData.ins ? additiveData.ins : '-'}}</text>
|
||||
</view>
|
||||
<view style="display: flex; margin-left: 20px; margin-right: 20px;">
|
||||
<t-tag wx:for="{{additiveData.functions}}" wx:key="index" wx:for-item="item" variant="light-outline" theme="primary">{{item}}</t-tag>
|
||||
<view style="display: flex; margin-left: 20px; margin-right: 20px; flex-wrap: wrap;">
|
||||
<t-tag wx:for="{{additiveData.functions}}" wx:key="index" wx:for-item="item" variant="light-outline" theme="primary" style="margin-right: 5px; margin-bottom: 5px;">{{item}}</t-tag>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{additiveData.description != ''}}" class="main-item">
|
||||
<view class="main-title">描述</view>
|
||||
<view style="margin: 10px;">{{additiveData.description}}</view>
|
||||
</view>
|
||||
<view class="main-item">
|
||||
<view class="main-item" wx:if="{{additiveData.chemicals.length != 0}}">
|
||||
<view class="main-title">包含物质</view>
|
||||
<view class="chemical-item" wx:for="{{additiveData.chemicals}}" wx:key="index" wx:for-item="item" data-chemical="{{item.id}}" bindtap="onGoChemical">
|
||||
<view>
|
||||
|
||||
@ -9,7 +9,12 @@
|
||||
</view>
|
||||
<view class="home-page-container">
|
||||
<!-- <t-button bindtap="textButton"></t-button> -->
|
||||
<t-image t-class="searich_btn" shape="round" mode="heightFix" src="/images/search.jpg" bind:tap="uploadPicture" />
|
||||
<view class="container">
|
||||
<t-image t-class="search_img" shape="round" mode="heightFix" src="/images/check.png" />
|
||||
</view>
|
||||
<view class="container">
|
||||
<button class="search_btn" theme="default" size="large" bind:tap="uploadPicture" block>扫一扫</button>
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view class="home-page-ad"></view> -->
|
||||
<t-dialog visible="{{loadingDialog}}" cancel-btn="取消操作" bind:cancel="onCloseDialog">
|
||||
|
||||
@ -27,15 +27,30 @@ page {
|
||||
bottom: 82px;
|
||||
}
|
||||
|
||||
.home-page-container .searich_btn {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
top: 0;
|
||||
margin: auto;
|
||||
border-radius: 20px;
|
||||
box-shadow: 4px 4px 4px 4px rgb(187, 187, 187);
|
||||
.home-page-container {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
flex-wrap: wrap;
|
||||
margin-top: 100px;
|
||||
}
|
||||
|
||||
.search_img {
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
/* border-radius: 20px;
|
||||
box-shadow: -1px 4px 2px 4px rgb(187, 187, 187); */
|
||||
}
|
||||
|
||||
.search_btn {
|
||||
width: 100%;
|
||||
margin-left: 70px;
|
||||
margin-right: 70px;
|
||||
background-color: #ffcd38;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.home-page-container,
|
||||
|
||||
@ -3,6 +3,9 @@ import {
|
||||
sessionQuery,
|
||||
sessionAdditiveQuery
|
||||
} from '../../../services/api/session';
|
||||
import {
|
||||
sessionUpload
|
||||
} from '../../../services/api/session';
|
||||
|
||||
Page({
|
||||
|
||||
@ -18,18 +21,18 @@ Page({
|
||||
kinds: []
|
||||
},
|
||||
address: [],
|
||||
company: ["浏阳市青草学堂食品厂"],
|
||||
images: [""],
|
||||
licenseCode: ["SC11643018106863"],
|
||||
company: [],
|
||||
images: [],
|
||||
licenseCode: [],
|
||||
sessionId: 0,
|
||||
standard: "Q/AQCX0001S",
|
||||
standardType: "企业标准",
|
||||
tags: ["反式脂肪酸", "添加剂"],
|
||||
standard: "",
|
||||
standardType: "",
|
||||
tags: [],
|
||||
typeCode: "",
|
||||
typeName: "",
|
||||
rate: {
|
||||
level: 4,
|
||||
text: '不建议儿童食用',
|
||||
text: '',
|
||||
type: ''
|
||||
}
|
||||
},
|
||||
@ -43,6 +46,10 @@ Page({
|
||||
onLoad(options) {
|
||||
this.sessionId = options?.sessionId;
|
||||
// this.sessionId = 76
|
||||
this.init();
|
||||
},
|
||||
|
||||
init() {
|
||||
sessionQuery({
|
||||
id: this.sessionId
|
||||
}).then(respose => {
|
||||
@ -55,7 +62,7 @@ Page({
|
||||
}
|
||||
})
|
||||
sessionAdditiveQuery({
|
||||
id: this.data.sessionId
|
||||
id: this.sessionId
|
||||
}).then(respose => {
|
||||
this.setData({
|
||||
additives: respose.content.additives
|
||||
@ -129,10 +136,42 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
onAddImage() {
|
||||
if (this.sessionId == 0) {
|
||||
return
|
||||
}
|
||||
wx.chooseMedia({
|
||||
count: 1,
|
||||
mediaType: ['image'],
|
||||
sourceType: ['album', 'camera'],
|
||||
maxDuration: 30,
|
||||
camera: 'back',
|
||||
success: (res) => {
|
||||
if (res.tempFiles.length >= 1) {
|
||||
sessionUpload({
|
||||
urls: res.tempFiles,
|
||||
session: this.sessionId
|
||||
}).then(tmp => {
|
||||
console.log(tmp);
|
||||
if (tmp.code == 10000) {
|
||||
this.init();
|
||||
}
|
||||
})
|
||||
} else {}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
onGoAdditive(event) {
|
||||
const additiveId = event.currentTarget.dataset.additive;
|
||||
wx.navigateTo({
|
||||
url: `/pages/home/additive/additive?additiveId=${additiveId}`,
|
||||
});
|
||||
},
|
||||
onGoChemical(event) {
|
||||
const chemicalId = event.currentTarget.dataset.chemical;
|
||||
wx.navigateTo({
|
||||
url: `/pages/home/chemical/chemical?chemicalId=${chemicalId}`,
|
||||
});
|
||||
}
|
||||
})
|
||||
@ -13,7 +13,7 @@
|
||||
<view class="header-time">{{pageData.createTime}}</view>
|
||||
</view>
|
||||
<view class="right">
|
||||
<t-icon class="header-icon" data-name="add-rectangle" name="add-rectangle" size="64rpx" bind:click="onIconTap" />
|
||||
<t-icon class="header-icon" data-name="add-rectangle" name="add-rectangle" size="64rpx" bind:click="onAddImage" />
|
||||
<t-badge count="{{pageData.images.length}}" color="#0052d9" offset="{{ [64, 8] }}">
|
||||
<image class="header-image" wx:if="{{ pageData.images.length >= 1 }}" src="{{ pageData.images[0] }} " bindtap="onShowImages"></image>
|
||||
</t-badge>
|
||||
@ -108,7 +108,7 @@
|
||||
</view>
|
||||
<view class="additive-standard">{{item.standard}}</view>
|
||||
<view class="body-key" style="margin-bottom: 10px;" wx:if="{{item.chemicals.lenth != 0}}">所含元素:</view>
|
||||
<view class="additive-chemical" wx:for="{{item.chemicals}}" wx:key="index" wx:for-item="chemical">
|
||||
<view class="additive-chemical" wx:for="{{item.chemicals}}" wx:key="index" wx:for-item="chemical" data-chemical="{{chemical.id}}" bindtap="onGoChemical">
|
||||
<view class="additive-chemical-left">
|
||||
<view class="additive-chemical-name">{{chemical.name}}</view>
|
||||
<view class="additive-chemical-cas">{{chemical.cas}}</view>
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
import {
|
||||
sessionStandardList
|
||||
} from '../../../services/api/standard';
|
||||
import Message from 'tdesign-miniprogram/message/index';
|
||||
|
||||
Page({
|
||||
|
||||
@ -42,19 +43,41 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
getStandardList() {
|
||||
getStandardList(append) {
|
||||
const params = {
|
||||
pageNumber: this.data.page.num,
|
||||
pageSize: this.data.page.size
|
||||
}
|
||||
if (this.data.searchValue) {
|
||||
params['search'] = this.data.searchValue
|
||||
sessionStandardList(params).then(respose => {
|
||||
this.setData({
|
||||
standardList: respose.content.contentList,
|
||||
"page.total": respose.content.total
|
||||
if (append) {
|
||||
sessionStandardList(params).then(respose => {
|
||||
this.setData({
|
||||
standardList: this.data.standardList.concat(respose.content.contentList),
|
||||
"page.total": respose.content.total
|
||||
})
|
||||
this.handleWarning();
|
||||
})
|
||||
})
|
||||
} else {
|
||||
sessionStandardList(params).then(respose => {
|
||||
this.setData({
|
||||
standardList: respose.content.contentList,
|
||||
"page.total": respose.content.total
|
||||
})
|
||||
this.handleWarning();
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
handleWarning() {
|
||||
if (this.data.standardList.length == 0) {
|
||||
Message.warning({
|
||||
context: this,
|
||||
offset: [20, 32],
|
||||
duration: 5000,
|
||||
content: '未查询到该信息,请重新尝试!',
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
@ -97,7 +120,15 @@ Page({
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
console.log(this.data.standardList.length);
|
||||
if (this.data.standardList.length >= this.data.page.total) {
|
||||
return
|
||||
}
|
||||
const num = this.data.page.num;
|
||||
this.setData({
|
||||
"page.num": num + 1
|
||||
})
|
||||
this.getStandardList(true);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@ -1,8 +1,13 @@
|
||||
{
|
||||
"navigationBarTitleText": "标准",
|
||||
"onReachBottomDistance": 10,
|
||||
"backgroundTextStyle": "light",
|
||||
"usingComponents": {
|
||||
"t-search": "tdesign-miniprogram/search/search",
|
||||
"t-tag": "tdesign-miniprogram/tag/tag",
|
||||
"t-check-tag": "tdesign-miniprogram/tag/check-tag",
|
||||
"t-sticky": "tdesign-miniprogram/sticky/sticky",
|
||||
"t-message": "tdesign-miniprogram/message/message",
|
||||
"t-image": "tdesign-miniprogram/image/image"
|
||||
}
|
||||
}
|
||||
@ -1,9 +1,11 @@
|
||||
<!--pages/standard/list/index.wxml-->
|
||||
<view class="main">
|
||||
<view>
|
||||
<view wx:if="{{standardList.length == 0}}" class="top-empty"></view>
|
||||
<view class="search-view">
|
||||
<t-search t-class="search" placeholder="搜索标准" shape="round" bind:submit="doSearch" bind:clear="doSearchClear" value="{{searchValue}}" />
|
||||
</view>
|
||||
<t-sticky disabled="{{standardList.length == 0}}">
|
||||
<view class="search-view">
|
||||
<t-search t-class="search" placeholder="搜索标准" shape="round" bind:submit="doSearch" bind:clear="doSearchClear" value="{{searchValue}}" />
|
||||
</view>
|
||||
</t-sticky>
|
||||
<view wx:if="{{standardList.length == 0}}" class="standard-image">
|
||||
<t-image shape="round" mode="heightFix" src="/images/standard.jpg" bind:tap="uploadPicture" />
|
||||
</view>
|
||||
@ -17,4 +19,5 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<t-message id="t-message" />
|
||||
@ -12,6 +12,10 @@
|
||||
.search-view {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
width: 100%;
|
||||
background-color: rgb(255, 255, 255);
|
||||
}
|
||||
|
||||
.search {
|
||||
@ -25,8 +29,7 @@
|
||||
}
|
||||
|
||||
.list-view {
|
||||
margin: 10px;
|
||||
margin-top: 20px;
|
||||
padding: 10px;
|
||||
margin-bottom: 80px;
|
||||
}
|
||||
|
||||
|
||||
114
pages/user/edit/index.js
Normal file
114
pages/user/edit/index.js
Normal file
@ -0,0 +1,114 @@
|
||||
// pages/user/edit/index.js
|
||||
|
||||
import {
|
||||
getUserInfo,
|
||||
updateUserInfo
|
||||
} from '../../../services/permission/user'
|
||||
|
||||
const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
|
||||
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
avatarUrl: defaultAvatarUrl,
|
||||
nickname: ""
|
||||
},
|
||||
|
||||
onChooseAvatar(e) {
|
||||
const {
|
||||
avatarUrl
|
||||
} = e.detail
|
||||
console.log(avatarUrl);
|
||||
this.setData({
|
||||
avatarUrl,
|
||||
})
|
||||
},
|
||||
|
||||
onSave() {
|
||||
console.log(this.data.nickname);
|
||||
console.log(this.data.avatarUrl);
|
||||
updateUserInfo({
|
||||
nickname: this.data.nickname,
|
||||
avatar: this.data.avatarUrl
|
||||
}).then(res => {
|
||||
console.log(res);
|
||||
wx.switchTab({
|
||||
url: `../index`,
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
onInput(e) {
|
||||
const nickname = e.detail.value;
|
||||
this.setData({
|
||||
nickname
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
const tmp = getUserInfo();
|
||||
let avatar = tmp.avatar
|
||||
if (avatar == '') {
|
||||
avatar = defaultAvatarUrl
|
||||
}
|
||||
this.setData({
|
||||
avatarUrl: avatar,
|
||||
nickname: tmp.nickname
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
}
|
||||
})
|
||||
9
pages/user/edit/index.json
Normal file
9
pages/user/edit/index.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"navigationBarTitleText": "修改信息",
|
||||
"onReachBottomDistance": 10,
|
||||
"backgroundTextStyle": "light",
|
||||
"usingComponents": {
|
||||
"t-input": "tdesign-miniprogram/input/input",
|
||||
"t-button": "tdesign-miniprogram/button/button"
|
||||
}
|
||||
}
|
||||
9
pages/user/edit/index.wxml
Normal file
9
pages/user/edit/index.wxml
Normal file
@ -0,0 +1,9 @@
|
||||
<!--pages/user/edit/index.wxml-->
|
||||
<button class="avatar-wrapper" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar">
|
||||
<image class="avatar" src="{{avatarUrl}}"></image>
|
||||
</button>
|
||||
<t-input type="nickname" value="{{nickname}}" bind:change="onInput" data-key="nickname" label="昵称" t-class="weui-input" placeholder="请输入昵称" />
|
||||
|
||||
<view class="button-example">
|
||||
<t-button t-class="button-save" theme="primary" size="large" bindtap="onSave" block>确认保存</t-button>
|
||||
</view>
|
||||
24
pages/user/edit/index.wxss
Normal file
24
pages/user/edit/index.wxss
Normal file
@ -0,0 +1,24 @@
|
||||
/* pages/user/edit/index.wxss */
|
||||
|
||||
.avatar-wrapper {
|
||||
margin-top: 100px;
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 54px;
|
||||
height: 54px;
|
||||
}
|
||||
|
||||
.weui-input {
|
||||
margin-top: 50px;
|
||||
}
|
||||
|
||||
.button-example {
|
||||
margin: 0 32rpx;
|
||||
margin-top: 100px;
|
||||
}
|
||||
@ -4,6 +4,10 @@ import {
|
||||
isLogin
|
||||
} from '../../services/permission/login';
|
||||
|
||||
import {
|
||||
getUserInfo
|
||||
} from '../../services/permission/user'
|
||||
|
||||
Page({
|
||||
|
||||
/**
|
||||
@ -11,6 +15,11 @@ Page({
|
||||
*/
|
||||
data: {
|
||||
loginStatus: false,
|
||||
userinfo: {
|
||||
nickname: "",
|
||||
avatar: ""
|
||||
},
|
||||
avatarImage: ""
|
||||
},
|
||||
|
||||
/**
|
||||
@ -20,6 +29,33 @@ Page({
|
||||
this.setData({
|
||||
loginStatus: isLogin()
|
||||
})
|
||||
const tmp = getUserInfo()
|
||||
this.setData({
|
||||
userinfo: {
|
||||
...tmp
|
||||
}
|
||||
})
|
||||
if (this.data.userinfo.avatar == "") {
|
||||
this.setData({
|
||||
avatarImage: 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
|
||||
});
|
||||
} else {
|
||||
this.setData({
|
||||
avatarImage: this.data.userinfo.avatar
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
onGoSessionList() {
|
||||
wx.navigateTo({
|
||||
url: `/pages/user/session-list/index`,
|
||||
});
|
||||
},
|
||||
|
||||
onGoEdit() {
|
||||
wx.navigateTo({
|
||||
url: `/pages/user/edit/index`,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
@ -34,6 +70,13 @@ Page({
|
||||
*/
|
||||
onShow() {
|
||||
this.getTabBar().init();
|
||||
const tmp = getUserInfo()
|
||||
this.setData({
|
||||
userinfo: {
|
||||
...tmp
|
||||
},
|
||||
avatarImage: tmp.avatar
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@ -1,6 +1,12 @@
|
||||
{
|
||||
"navigationBarTitleText": "个人中心",
|
||||
"onReachBottomDistance": 10,
|
||||
"backgroundTextStyle": "light",
|
||||
"usingComponents": {
|
||||
"t-image": "/components/webp-image/index",
|
||||
"t-grid": "tdesign-miniprogram/grid/grid",
|
||||
"t-grid-item": "tdesign-miniprogram/grid/grid-item",
|
||||
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||
"t-avatar": "tdesign-miniprogram/avatar/avatar"
|
||||
}
|
||||
}
|
||||
@ -1,9 +1,20 @@
|
||||
<!--pages/user/index.wxml-->
|
||||
<view class="user-center-card">
|
||||
<view class="searich_btn">
|
||||
<t-avatar image="/images/weixin.png" class="user-center-card__header__avatar" />
|
||||
<view class="user-center-card__header__name">{{ loginStatus ? '微信用户' :'请登录'}}</view>
|
||||
<t-avatar image="{{avatarImage}}" class="user-center-card__header__avatar" bindtap="onGoEdit" />
|
||||
<view wx:if="{{loginStatus == false}}" class="user-center-card__header__name" bindtap="onGoEdit">请登录</view>
|
||||
<view wx:else class="user-center-card__header__name" bindtap="onGoEdit">{{ userinfo.nickname == '' ? '微信用户' : userinfo.nickname }}</view>
|
||||
<t-icon name="edit-1" bindtap="onGoEdit"></t-icon>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view></view>
|
||||
<view class="grid-view">
|
||||
<view class="grid-box">
|
||||
<t-grid class="block">
|
||||
<t-grid-item t-class="grid-item" text="查询记录" image="/images/history.png" bindtap="onGoSessionList" />
|
||||
<t-grid-item t-class="grid-item" text="问题反馈" image="/images/question.png" />
|
||||
<!-- <t-grid-item text="保存" icon="download" />
|
||||
<t-grid-item text="编辑" icon="edit-1" /> -->
|
||||
</t-grid>
|
||||
</view>
|
||||
</view>
|
||||
@ -26,6 +26,7 @@
|
||||
.user-center-card__header__avatar {
|
||||
width: 96rpx;
|
||||
height: 96rpx;
|
||||
margin-left: 15px;
|
||||
border-radius: 48rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
@ -35,6 +36,35 @@
|
||||
line-height: 48rpx;
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
margin-left: 24rpx;
|
||||
margin-left: 32rpx;
|
||||
margin-right: 16rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.block {
|
||||
display: block;
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.grid-view {
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
top: 320rpx;
|
||||
/* padding: 20px; */
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
.grid-box {
|
||||
--tw-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
|
||||
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
|
||||
/* border-style: solid;
|
||||
border-width: 2px;
|
||||
border-color: rgba(230, 230, 230, 0.719); */
|
||||
margin: 20px;
|
||||
padding: 10px;
|
||||
padding-bottom: 5px;
|
||||
border-radius: 0.75rem;
|
||||
background-color: #ffffff;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.grid-item {}
|
||||
120
pages/user/session-list/index.js
Normal file
120
pages/user/session-list/index.js
Normal file
@ -0,0 +1,120 @@
|
||||
// pages/user/session-list/index.js
|
||||
|
||||
import {
|
||||
sessionList
|
||||
} from '../../../services/api/session';
|
||||
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
sessionDataList: [],
|
||||
page: {
|
||||
num: 1,
|
||||
size: 20,
|
||||
total: 0
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
|
||||
this.getSessionList();
|
||||
},
|
||||
|
||||
getSessionList(append) {
|
||||
const params = {
|
||||
pageNumber: this.data.page.num,
|
||||
pageSize: this.data.page.size
|
||||
}
|
||||
if (append) {
|
||||
sessionList(params).then(respose => {
|
||||
this.setData({
|
||||
sessionDataList: this.data.sessionDataList.concat(respose.content.contentList),
|
||||
"page.total": respose.content.total
|
||||
})
|
||||
})
|
||||
} else {
|
||||
sessionList(params).then(respose => {
|
||||
this.setData({
|
||||
sessionDataList: respose.content.contentList,
|
||||
"page.total": respose.content.total
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
onGoSession(e) {
|
||||
console.log(e);
|
||||
const session = e.currentTarget.dataset.session;
|
||||
this.goSession(session);
|
||||
},
|
||||
|
||||
goSession(sessionId) {
|
||||
wx.navigateTo({
|
||||
url: `/pages/home/session/session?sessionId=${sessionId}`,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
console.log(this.data.sessionDataList.length);
|
||||
if (this.data.sessionDataList.length >= this.data.page.total) {
|
||||
return
|
||||
}
|
||||
const num = this.data.page.num;
|
||||
this.setData({
|
||||
"page.num": num + 1
|
||||
})
|
||||
this.getSessionList(true);
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
}
|
||||
})
|
||||
9
pages/user/session-list/index.json
Normal file
9
pages/user/session-list/index.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"navigationBarTitleText": "查询记录",
|
||||
"onReachBottomDistance": 10,
|
||||
"backgroundTextStyle": "light",
|
||||
"usingComponents": {
|
||||
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||
"t-avatar": "tdesign-miniprogram/avatar/avatar"
|
||||
}
|
||||
}
|
||||
20
pages/user/session-list/index.wxml
Normal file
20
pages/user/session-list/index.wxml
Normal file
@ -0,0 +1,20 @@
|
||||
<!--pages/user/session-list/index.wxml-->
|
||||
<view class="main">
|
||||
<view class="top-title">查询记录</view>
|
||||
<view class="top-content">您已通过该软件查询物品{{page.total}}次</view>
|
||||
<view class="history-list">
|
||||
<view class="history-item" wx:for="{{sessionDataList}}" wx:key="index" wx:for-item="item" data-session="{{item.id}}" bindtap="onGoSession">
|
||||
<view class="history-left">
|
||||
<t-avatar t-class="history-avatar" image="{{item.images[0]}}" />
|
||||
<view class="history-content">
|
||||
<view class="history-title">{{item.createTime}}</view>
|
||||
<view class="history-text">{{item.additive}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="history-right">
|
||||
<t-icon color="rgb(255, 191, 52)" name="star-filled" size="48rpx" data-name="star-filled" />
|
||||
<view>{{item.rate}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
62
pages/user/session-list/index.wxss
Normal file
62
pages/user/session-list/index.wxss
Normal file
@ -0,0 +1,62 @@
|
||||
/* pages/user/session-list/index.wxss */
|
||||
|
||||
.main {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.top-title {
|
||||
font-size: 1.5rem;
|
||||
line-height: 2rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.top-content {
|
||||
color: rgb(150, 150, 150);
|
||||
margin-left: 10px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.history-item {
|
||||
--tw-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
|
||||
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
|
||||
border-style: solid;
|
||||
border-width: 2px;
|
||||
border-color: rgba(230, 230, 230, 0.719);
|
||||
margin: 5px;
|
||||
margin-top: 10px;
|
||||
padding: 10px;
|
||||
padding-top: 15px;
|
||||
padding-bottom: 20px;
|
||||
border-radius: 0.75rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.history-left {
|
||||
width: 100%;
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
.history-avatar {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.history-title {
|
||||
font-weight: 600;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.history-text {
|
||||
color: rgb(150, 150, 150);
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.25rem;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.history-right {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
color: rgb(255, 191, 52);
|
||||
}
|
||||
@ -1,29 +1,15 @@
|
||||
<t-user-center-card userInfo="{{userInfo}}" isPhoneHide="{{true}}" name-class="custom-name-class" phone-class="custom-phone-class" avatar-class="custome-avatar-class" currAuthStep="{{currAuthStep}}" bind:gotoUserEditPage="gotoUserEditPage" />
|
||||
<view class="content-wrapper">
|
||||
<!-- <view class='order-group-wrapper'>
|
||||
<view class='order-group-wrapper'>
|
||||
<t-order-group orderTagInfos="{{orderTagInfos}}" bind:onClickTop="jumpAllOrder" bind:onClickItem="jumpNav" />
|
||||
</view> -->
|
||||
<!-- <view wx:for="{{menuData}}" wx:key="item" class="cell-box">
|
||||
<t-cell-group>
|
||||
<t-cell
|
||||
wx:for="{{item}}"
|
||||
wx:for-item="xitem"
|
||||
wx:for-index="xindex"
|
||||
wx:key="xindex"
|
||||
title="{{xitem.title}}"
|
||||
arrow="{{!xitem.icon}}"
|
||||
note="{{xitem.tit}}"
|
||||
data-type="{{xitem.type}}"
|
||||
bordered="{{false}}"
|
||||
bind:click="onClickCell"
|
||||
t-class="t-cell-padding"
|
||||
t-class-note="order-group-note"
|
||||
t-class-left="order-group__left"
|
||||
>
|
||||
<t-icon name="{{xitem.icon}}" size="48rpx" slot="note" />
|
||||
</t-cell>
|
||||
</t-cell-group>
|
||||
</view> -->
|
||||
</view>
|
||||
<view wx:for="{{menuData}}" wx:key="item" class="cell-box">
|
||||
<t-cell-group>
|
||||
<t-cell wx:for="{{item}}" wx:for-item="xitem" wx:for-index="xindex" wx:key="xindex" title="{{xitem.title}}" arrow="{{!xitem.icon}}" note="{{xitem.tit}}" data-type="{{xitem.type}}" bordered="{{false}}" bind:click="onClickCell" t-class="t-cell-padding" t-class-note="order-group-note" t-class-left="order-group__left">
|
||||
<t-icon name="{{xitem.icon}}" size="48rpx" slot="note" />
|
||||
</t-cell>
|
||||
</t-cell-group>
|
||||
</view>
|
||||
</view>
|
||||
<view class="footer__version" wx:if="{{versionNo !== ''}}">当前版本 {{versionNo}}</view>
|
||||
<t-popup visible="{{showMakePhone}}" placement="bottom" bind:visible-change="closeMakePhone" data-index="2">
|
||||
|
||||
@ -11,6 +11,13 @@ export function request({
|
||||
method
|
||||
}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (getToken() == '' && path != '/wx/login') {
|
||||
wx.showToast({
|
||||
title: '请登录后再次尝试。',
|
||||
icon: 'error',
|
||||
duration: 3000
|
||||
})
|
||||
}
|
||||
wx.request({
|
||||
url: baseURL + path, //仅为示例,并非真实的接口地址
|
||||
data: params,
|
||||
|
||||
@ -20,20 +20,19 @@ export function sessionUpload({
|
||||
})
|
||||
})
|
||||
} else {
|
||||
for (let index = 0; index < urls.length; index++) {
|
||||
const element = urls[index];
|
||||
return new Promise((resolve, reject) => {
|
||||
uploadFile({
|
||||
path: '/ocr/upload',
|
||||
url: element.tempFilePath,
|
||||
url: urls[0].tempFilePath,
|
||||
data: {
|
||||
sessionId: session
|
||||
}
|
||||
}).then(res => {
|
||||
console.log(res);
|
||||
const tmp = JSON.parse(res)
|
||||
reject(tmp)
|
||||
resolve(tmp)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,4 +66,12 @@ export function sessionAdditiveChemical(params) {
|
||||
params: params,
|
||||
method: 'GET'
|
||||
});
|
||||
}
|
||||
|
||||
export function sessionList(params) {
|
||||
return request({
|
||||
path: '/session/list',
|
||||
params: params,
|
||||
method: 'GET'
|
||||
});
|
||||
}
|
||||
28
services/api/user.js
Normal file
28
services/api/user.js
Normal file
@ -0,0 +1,28 @@
|
||||
import {
|
||||
request,
|
||||
uploadFile
|
||||
} from './request'
|
||||
|
||||
export function userInfoQuery(params) {
|
||||
return request({
|
||||
path: '/wx/userinfo',
|
||||
params: params,
|
||||
method: 'GET'
|
||||
});
|
||||
}
|
||||
|
||||
export function userInfoUpdate(params) {
|
||||
return new Promise((resolve, reject) => {
|
||||
uploadFile({
|
||||
path: '/wx/userinfo',
|
||||
url: params.avatar,
|
||||
data: {
|
||||
nickname: params.nickname
|
||||
}
|
||||
}).then(res => {
|
||||
console.log(res);
|
||||
const tmp = JSON.parse(res)
|
||||
resolve(tmp)
|
||||
})
|
||||
})
|
||||
}
|
||||
@ -1,10 +1,14 @@
|
||||
import {
|
||||
wxLogin
|
||||
} from '../api/permission'
|
||||
import {
|
||||
setUserInfo
|
||||
} from './user'
|
||||
|
||||
var token = ''
|
||||
|
||||
export function isLogin() {
|
||||
// console.log(token);
|
||||
if (token == '') {
|
||||
return new Promise((resolve, reject) => {
|
||||
wx.login({
|
||||
@ -14,7 +18,8 @@ export function isLogin() {
|
||||
wxLogin({
|
||||
code: res.code
|
||||
}).then(respose => {
|
||||
token = respose.content.token
|
||||
token = respose.content.token;
|
||||
setUserInfo(respose.content);
|
||||
resolve(true);
|
||||
})
|
||||
} else {
|
||||
|
||||
41
services/permission/user.js
Normal file
41
services/permission/user.js
Normal file
@ -0,0 +1,41 @@
|
||||
import {
|
||||
userInfoQuery,
|
||||
userInfoUpdate
|
||||
} from '../api/user'
|
||||
|
||||
const userInfo = {
|
||||
nickname: "",
|
||||
avatar: ""
|
||||
}
|
||||
|
||||
export function setUserInfo(info) {
|
||||
userInfo.avatar = info.avatar;
|
||||
userInfo.nickname = info.nickname;
|
||||
}
|
||||
|
||||
export function getUserInfo() {
|
||||
if (userInfo.avatar == '' || userInfo.nickname == '') {
|
||||
userInfoQuery().then(respose => {
|
||||
if (respose.code == 10000) {
|
||||
userInfo.avatar = respose.content.avatar;
|
||||
userInfo.nickname = respose.content.nickname;
|
||||
}
|
||||
})
|
||||
}
|
||||
const tmp = {
|
||||
...userInfo
|
||||
};
|
||||
return tmp;
|
||||
}
|
||||
|
||||
export function updateUserInfo(info) {
|
||||
return new Promise((resolve, reject) => {
|
||||
userInfoUpdate(info).then(respose => {
|
||||
if (respose.code == 10000) {
|
||||
userInfo.avatar = info.avatar;
|
||||
userInfo.nickname = info.nickname;
|
||||
resolve(info)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user