一大波需求

This commit is contained in:
2025-04-15 20:23:27 +08:00
parent 328129d94e
commit f116020bbc
31 changed files with 874 additions and 77 deletions

View File

@ -44,8 +44,13 @@ class Request {
this.loginRoutePromise = null;
})
throw new Error(response.data)
}
}else if(response.statusCode==200){
//接口的 code
if(response.data.code==200){
return response;
}
}
throw new Error(response.data)
});
}
@ -85,6 +90,12 @@ class Request {
const processedResponse = await this.processResponseInterceptors(res);
resolve(processedResponse.data.data);
} catch (error) {
if(!config.ignoreError){
wx.showToast({
icon:'error',
title: response.data.message||'未知错误',
})
}
reject(error);
}
},

View File

@ -1,8 +1,12 @@
import request from './request';
const userAPI = {
login(code){
return request.post('/api/v1/auth/login/wechat',{code})
login(code,referral_code){
const params = {code};
if(referral_code){
params.referral_code = referral_code;
}
return request.post('/api/v1/auth/login/wechat',params)
},
/**
* 获取用户信息
@ -16,7 +20,7 @@ const userAPI = {
* @param {object} data - 用户信息
*/
updateInfo(data) {
return request.put('/api/v1/user/info', data);
return request.put('/api/v1/users/me', data);
},
/**
@ -63,8 +67,14 @@ const userAPI = {
getPersonImages(data){
return request.get('/api/v1/person-images',data)
},
updatePersonImageDefault(image_id){
return request.put(`/api/v1/person-images/${image_id}/set_default`)
},
getDefaultPersonImage(){
return request.get('/api/v1/person-images/default')
return request.get('/api/v1/person-images/default',{},{ignoreError:true})
},
deletePersonImage(image_id){
return request.delete(`/api/v1/person-images/${image_id}`)
},
tryOnStatus:{
trying:'生成中',error:'失败',success:'已生成'

68
app.js
View File

@ -1,10 +1,76 @@
import userAPI from './api/user';
App({
shareTitle:'我的美搭,分享给你',
onLaunch() {
wx.onAppRoute((res)=>{
const page = getCurrentPages();
const currentPage = page[page.length-1];
if(currentPage&&!currentPage.useCustomShare){
currentPage.onShareAppMessage = async()=>{
let path = '/pages/try/index/index';
const token = wx.getStorageSync('token');
if(token){
if(!(this.globalData.userInfo&&this.globalData.userInfo.user_code)){
await this.getUserInfo();
}
if(this.globalData.userInfo.user_code){
path = `${path}?shared_user_code=${this.globalData.userInfo.user_code}`;
}
}
return {
title:this.shareTitle,
imageUrl:'/assets/img/share.jpg',
path:path
}
}
}
})
},
onShow(options){
console.log(options);
if(options.query.shared_user_code){
this.globalData.shared_user_code = options.query.shared_user_code;
}
this.checkUpdate();
},
forceGetUserInfo(){
this.globalData.userInfoGetTime = null;
return this.getUserInfo();
},
async getUserInfo(){
if(this.globalData.userInfoGetTime&&
this.globalData.userInfo&&
new Date()-this.globalData.userInfoGetTime<1000*60*10){
return this.globalData.userInfo;
}
const data = await userAPI.getInfo();
this.globalData.userInfo = data;
this.globalData.userInfoGetTime = new Date();
return data;
},
globalData: {
userInfo: null
},
checkUpdate() {
if (!wx.canIUse('getUpdateManager')) {
return;
}
const updateManager = wx.getUpdateManager();
updateManager.onCheckForUpdate((res) => {
console.log(res);
});
updateManager.onUpdateReady(() => {
wx.showModal({
title: '更新提示',
content: '新版本已准备好,重启应用以使用新版本',
showCancel: false,
success: (res) => {
if (res.confirm) {
updateManager.applyUpdate();
}
}
});
});
}
})

View File

@ -1,9 +1,12 @@
{
"pages": [
"pages/try/index/index",
"pages/my/images/index",
"pages/my/login/index",
"pages/closet/index/index",
"pages/my/index/index"
"pages/my/index/index",
"pages/my/setting/index",
"pages/my/setting/name/index"
],
"window": {
"navigationBarTextStyle": "black",

View File

@ -5,6 +5,7 @@ page{
--main-font-color:#333;
--safe-bottom:constant(safe-area-inset-bottom);
--safe-bottom:env(safe-area-inset-bottom);
--active-bg-color:rgba(200,200,200,.1);
background-color: var(--main-bgclolor);
font-size: 30rpx;
color: var(--main-font-color);
@ -12,21 +13,36 @@ page{
height: 100vw;
overflow: hidden;
}
.page{
padding:20rpx;
}
.page-head{
padding:0 20rpx;
font-size: 52rpx;
font-weight: bold;
}
button{
border-radius: 40rpx;
border-radius: 80rpx;
background-color: #000;
color: #fff;
margin:0;
transition-duration: .4s;
margin:0;
}
button[type=primary]{
background-color: #000;
wx-button:not([size=mini]){
padding-top:26rpx;
padding-bottom:26rpx;
width: auto;
}
button.button-hover{
background-color: #000!important;
opacity: .8;
wx-button[type=primary]{
background-color: #000;
}
button[loading][type=primary] {
background-color:#000;
color: hsla(0,0%,100%,.6);
}
wx-button[type=primary].button-hover{
background-color: #666;
}
button.icon-button{
width:60rpx;height:60rpx;
@ -97,7 +113,7 @@ radio .wx-radio-input.wx-radio-input-checked::before{
.cells .cell.cell-active{
background-color:rgba(0,0,0,.1);
}
.cells .cell::after{
.cells .cell::before{
content: '';
border-bottom: 1rpx solid rgba(153, 153, 153, 0.2);
position: absolute;
@ -105,7 +121,7 @@ radio .wx-radio-input.wx-radio-input-checked::before{
left:40rpx;
right:40rpx;
}
.cells .cell:last-child::after{
.cells .cell:last-child::before{
border:0;
}
.cells .cell-hd{
@ -139,6 +155,9 @@ radio .wx-radio-input.wx-radio-input-checked::before{
.cells.cells-access .cell-ft{
padding-right: 40rpx;
}
.cells.cells-access .cell:active{
background-color: var(--active-bg-color);
}
.cells.cells-access .cell-ft::after{
content:" ";
width:24rpx;height:48rpx;
@ -152,3 +171,12 @@ radio .wx-radio-input.wx-radio-input-checked::before{
color:var(--weui-FG-2);
-webkit-mask-image:url(data:image/svg+xml,%3Csvg%20width%3D%2212%22%20height%3D%2224%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M2.454%206.58l1.06-1.06%205.78%205.779a.996.996%200%20010%201.413l-5.78%205.779-1.06-1.061%205.425-5.425-5.425-5.424z%22%20fill%3D%22%23B2B2B2%22%20fill-rule%3D%22evenodd%22%2F%3E%3C%2Fsvg%3E);mask-image:url(data:image/svg+xml,%3Csvg%20width%3D%2212%22%20height%3D%2224%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M2.454%206.58l1.06-1.06%205.78%205.779a.996.996%200%20010%201.413l-5.78%205.779-1.06-1.061%205.425-5.425-5.425-5.424z%22%20fill%3D%22%23B2B2B2%22%20fill-rule%3D%22evenodd%22%2F%3E%3C%2Fsvg%3E);position:absolute;top:50%;right:0;margin-top:-24rpx
}
.navigator-hover{
background-color: transparent;
opacity: 1;
}
navigator:active{
background-color: var(--active-bg-color);
}

View File

@ -47,6 +47,10 @@
mask-image: var(--icon-delete);
-webkit-mask-image: var(--icon-delete);
}
.icon.close{
mask-image: var(--icon-close);
-webkit-mask-image: var(--icon-close);
}
.icon.history{
mask-image: var(--icon-history);
-webkit-mask-image: var(--icon-history);
@ -81,5 +85,6 @@ page{
--icon-loading:url(data:image/svg+xml,%3C%3Fxml%20version%3D%271.0%27%20encoding%3D%27UTF-8%27%3F%3E%3Csvg%20width%3D%2780px%27%20height%3D%2780px%27%20viewBox%3D%270%200%2080%2080%27%20version%3D%271.1%27%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20xmlns%3Axlink%3D%27http%3A//www.w3.org/1999/xlink%27%3E%3Ctitle%3Eloading%3C/title%3E%3Cdefs%3E%3ClinearGradient%20x1%3D%2794.0869141%25%27%20y1%3D%270%25%27%20x2%3D%2794.0869141%25%27%20y2%3D%2790.559082%25%27%20id%3D%27linearGradient-1%27%3E%3Cstop%20stop-color%3D%27%23606060%27%20stop-opacity%3D%270%27%20offset%3D%270%25%27%3E%3C/stop%3E%3Cstop%20stop-color%3D%27%23606060%27%20stop-opacity%3D%270.3%27%20offset%3D%27100%25%27%3E%3C/stop%3E%3C/linearGradient%3E%3ClinearGradient%20x1%3D%27100%25%27%20y1%3D%278.67370605%25%27%20x2%3D%27100%25%27%20y2%3D%2790.6286621%25%27%20id%3D%27linearGradient-2%27%3E%3Cstop%20stop-color%3D%27%23606060%27%20offset%3D%270%25%27%3E%3C/stop%3E%3Cstop%20stop-color%3D%27%23606060%27%20stop-opacity%3D%270.3%27%20offset%3D%27100%25%27%3E%3C/stop%3E%3C/linearGradient%3E%3C/defs%3E%3Cg%20stroke%3D%27none%27%20stroke-width%3D%271%27%20fill%3D%27none%27%20fill-rule%3D%27evenodd%27%20opacity%3D%270.9%27%3E%3Cg%3E%3Cpath%20d%3D%27M40%2C0%20C62.09139%2C0%2080%2C17.90861%2080%2C40%20C80%2C62.09139%2062.09139%2C80%2040%2C80%20L40%2C73%20C58.2253967%2C73%2073%2C58.2253967%2073%2C40%20C73%2C21.7746033%2058.2253967%2C7%2040%2C7%20L40%2C0%20Z%27%20fill%3D%27url%28%23linearGradient-1%29%27%3E%3C/path%3E%3Cpath%20d%3D%27M40%2C0%20L40%2C7%20C21.7746033%2C7%207%2C21.7746033%207%2C40%20C7%2C58.2253967%2021.7746033%2C73%2040%2C73%20L40%2C80%20C17.90861%2C80%200%2C62.09139%200%2C40%20C0%2C17.90861%2017.90861%2C0%2040%2C0%20Z%27%20fill%3D%27url%28%23linearGradient-2%29%27%3E%3C/path%3E%3Ccircle%20id%3D%27Oval%27%20fill%3D%27%23606060%27%20cx%3D%2740.5%27%20cy%3D%273.5%27%20r%3D%273.5%27%3E%3C/circle%3E%3C/g%3E%3CanimateTransform%20attributeName%3D%27transform%27%20begin%3D%270s%27%20dur%3D%271s%27%20type%3D%27rotate%27%20values%3D%270%2040%2040%3B360%2040%2040%27%20repeatCount%3D%27indefinite%27/%3E%3C/g%3E%3C/svg%3E);
--icon-warn:url(data:image/svg+xml,%3Csvg%20t%3D%221744472102058%22%20class%3D%22icon%22%20viewBox%3D%220%200%201024%201024%22%20version%3D%221.1%22%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20p-id%3D%2255997%22%20width%3D%22128%22%20height%3D%22128%22%3E%3Cpath%20d%3D%22M512%200C229.205333%200%200%20229.205333%200%20512s229.205333%20512%20512%20512%20512-229.205333%20512-512S794.794667%200%20512%200z%20m0%20796.458667A56.917333%2056.917333%200%201%201%20511.957333%20682.666667%2056.917333%2056.917333%200%200%201%20512%20796.458667z%20m54.186667-227.797334h0.128a60.501333%2060.501333%200%200%201-53.802667%2055.893334c2.048%200.256%203.882667%201.152%205.973333%201.152h-11.818666c2.048%200%203.84-0.981333%205.845333-1.109334a59.093333%2059.093333%200%200%201-53.162667-55.893333l-13.056-284.16a54.314667%2054.314667%200%200%201%2054.613334-57.045333h26.282666a52.992%2052.992%200%200%201%2054.186667%2057.002666l-15.146667%20284.16z%22%20fill%3D%22%23B94343%22%20p-id%3D%2255998%22%3E%3C/path%3E%3C/svg%3E);
--icon-delete:url(data:image/svg+xml,%3Csvg%20t%3D%221744473381401%22%20class%3D%22icon%22%20viewBox%3D%220%200%201024%201024%22%20version%3D%221.1%22%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20p-id%3D%2258654%22%20width%3D%22128%22%20height%3D%22128%22%3E%3Cpath%20d%3D%22M512%200C228.864%200%200%20228.864%200%20512%200%20795.136%20228.864%201024%20512%201024%20795.136%201024%201024%20795.136%201024%20512%201024%20228.864%20795.136%200%20512%200ZM768%20695.808%20695.808%20768%20512%20584.192%20328.192%20768%20256%20695.808%20439.808%20512%20256%20328.192%20328.192%20256%20512%20439.808%20695.808%20256%20768%20328.192%20584.192%20512%20768%20695.808Z%22%20fill%3D%22%23000000%22%20p-id%3D%2258655%22%20data-spm-anchor-id%3D%22a313x.search_index.0.i52.389b3a81KbR0ru%22%3E%3C/path%3E%3C/svg%3E);
--icon-history:url(data:image/svg+xml,%3Csvg%20t%3D%221744605585155%22%20class%3D%22icon%22%20viewBox%3D%220%200%201024%201024%22%20version%3D%221.1%22%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20p-id%3D%2259650%22%20width%3D%22128%22%20height%3D%22128%22%3E%3Cpath%20d%3D%22M512.00768%2015.15008a496.19456%20496.19456%200%200%201%20351.38944%20145.63328l1.92896%202.176a496.768%20496.768%200%200%201-1.92896%20700.52864l-2.15424%201.60256a496.77952%20496.77952%200%200%201-700.65024-1.60256%20496.78976%20496.78976%200%200%201%200-702.43456v-0.2752h0.2752A494.51904%20494.51904%200%200%201%20512.00768%2015.15008z%20m217.07008%20458.60224H550.27712V169.71904a38.40768%2038.40768%200%201%200-76.81536%200v342.25664a38.85824%2038.85824%200%200%200%2038.54592%2038.528h217.07008c20.88832%200%2037.99424-17.34656%2037.99424-38.528a38.15936%2038.15936%200%200%200-37.99424-38.22336z%20m80.04608-259.0016a419.48288%20419.48288%200%200%200-297.11616-123.136c-116.43776%200-221.42848%2046.63296-297.69216%20123.136a421.504%20421.504%200%200%200%200%20594.47424%20420.77568%20420.77568%200%200%200%20593.20448%201.62688l1.60384-1.62688c76.0128-75.92064%20123.7504-181.15328%20123.7504-297.24928a419.904%20419.904%200%200%200-121.57184-295.59808l-2.176-1.62688z%22%20fill%3D%22%233B3F51%22%20p-id%3D%2259651%22%3E%3C/path%3E%3C/svg%3E)
--icon-history:url(data:image/svg+xml,%3Csvg%20t%3D%221744605585155%22%20class%3D%22icon%22%20viewBox%3D%220%200%201024%201024%22%20version%3D%221.1%22%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20p-id%3D%2259650%22%20width%3D%22128%22%20height%3D%22128%22%3E%3Cpath%20d%3D%22M512.00768%2015.15008a496.19456%20496.19456%200%200%201%20351.38944%20145.63328l1.92896%202.176a496.768%20496.768%200%200%201-1.92896%20700.52864l-2.15424%201.60256a496.77952%20496.77952%200%200%201-700.65024-1.60256%20496.78976%20496.78976%200%200%201%200-702.43456v-0.2752h0.2752A494.51904%20494.51904%200%200%201%20512.00768%2015.15008z%20m217.07008%20458.60224H550.27712V169.71904a38.40768%2038.40768%200%201%200-76.81536%200v342.25664a38.85824%2038.85824%200%200%200%2038.54592%2038.528h217.07008c20.88832%200%2037.99424-17.34656%2037.99424-38.528a38.15936%2038.15936%200%200%200-37.99424-38.22336z%20m80.04608-259.0016a419.48288%20419.48288%200%200%200-297.11616-123.136c-116.43776%200-221.42848%2046.63296-297.69216%20123.136a421.504%20421.504%200%200%200%200%20594.47424%20420.77568%20420.77568%200%200%200%20593.20448%201.62688l1.60384-1.62688c76.0128-75.92064%20123.7504-181.15328%20123.7504-297.24928a419.904%20419.904%200%200%200-121.57184-295.59808l-2.176-1.62688z%22%20fill%3D%22%233B3F51%22%20p-id%3D%2259651%22%3E%3C/path%3E%3C/svg%3E);
--icon-close:url(data:image/svg+xml,%3Csvg%20t%3D%221744706202919%22%20class%3D%22icon%22%20viewBox%3D%220%200%201024%201024%22%20version%3D%221.1%22%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20p-id%3D%2260727%22%20width%3D%22128%22%20height%3D%22128%22%3E%3Cpath%20d%3D%22M942.506667%200L512%20430.506667%2081.493333%200%200%2081.493333%20430.506667%20512%200%20942.506667%2081.493333%201024%20512%20593.493333%20942.506667%201024%201024%20942.506667%20593.493333%20512%201024%2081.493333%20942.506667%200z%22%20fill%3D%22%23000000%22%20p-id%3D%2260728%22%3E%3C/path%3E%3C/svg%3E)
}

BIN
assets/img/share.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -55,6 +55,16 @@ Component({
if(bottomHeight<100){
this.triggerEvent('loadMore');
}
},
loadMoreIfNeed(){
const query = this.createSelectorQuery();
query.select('#scrollView').scrollOffset();
query.exec((res)=>{
const bottomHeight = res[0].scrollHeight-res[0].scrollTop-this.data.scrollHeight;
if(bottomHeight<100){
this.triggerEvent('loadMore');
}
})
}
},
observers:{

View File

@ -1,3 +1,6 @@
:host{
display: block;
}
.scroll-view{
height:100%;
}

181
pages/my/images/index.js Normal file
View File

@ -0,0 +1,181 @@
import userAPI from '../../../api/user';
Page({
/**
* 页面的初始数据
*/
data: {
list:[],
scrollViewHeight:0,
autoBack:false,
pager:{limit:10,loading:false,loadAll:false,pageIndex:0,refreshTrigger:false}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
const windowInfo = wx.getWindowInfo();
this.setData({
autoBack:options.auto_back||false,
scrollViewHeight:windowInfo.windowHeight
});
this.data.pager.loading = false;
this.data.pager.loadAll = false;
this.loadList();
},
refreshList(){
this.data.pager.pageIndex = 0;
this.data.pager.loadAll = false;
this.setData({
pager:this.data.pager
});
this.loadList();
},
loadList(){
if(this.data.pager.loading||this.data.pager.loadAll){
return;
}
this.data.pager.loading = true;
this.setData({
pager:this.data.pager
});
userAPI.getPersonImages({
skip:this.data.pager.limit*this.data.pager.pageIndex,
limit:this.data.pager.limit
}).then((data)=>{
if(this.data.pager.pageIndex==0){
this.data.list = data;
}else{
this.data.list = this.data.list.concat(data);
}
this.data.pager.refreshTrigger = false;
this.data.pager.loading = false;
this.data.pager.pageIndex++;
if(data.length<this.data.pager.limit){
this.data.pager.loadAll = true;
}
this.setData({
list:this.data.list,
pager:this.data.pager
})
}).catch(()=>{
this.setData({
"pager.loading":false,
"pager.refreshTrigger":false
})
})
},
setDefault(event){
const item = event.currentTarget.dataset.item;
const index = event.currentTarget.dataset.index;
const defaultIndex = this.data.list.findIndex((item)=>item.is_default);
userAPI.updatePersonImageDefault(item.id).then((data)=>{
if(this.data.autoBack){
wx.navigateBack()
}else{
wx.showToast({
icon:'none',
title: '修改成功'
})
this.setData({
[`list[${defaultIndex}].is_default`]:false,
[`list[${index}].is_default`]:true
})
}
})
},
deleteImage(event){
const index = event.currentTarget.dataset.index;
const item = event.currentTarget.dataset.item;
wx.showModal({
title: '是否删除这个形象',
complete: (res) => {
if (res.confirm) {
this.confirmDelete(item,index);
}
}
})
},
confirmDelete(item,index){
// this.selectComponent('#listView').loadMoreIfNeed();
userAPI.deletePersonImage(item.id).then(async(data)=>{
if(item.is_default){
//找一个不是默认的形象
const newDefaultIndex = this.data.list.findIndex((item=>!item.is_default));
if(newDefaultIndex>-1){
const newDefault = this.data.list[newDefaultIndex];
await userAPI.updatePersonImageDefault(newDefault.id);
this.setData({
[`list[${newDefaultIndex}].is_default`]:true
})
}
}
if(this.data.pager.loadAll){
this.data.list.splice(index,1);
this.setData({
list:this.data.list
})
}else{
refreshList();
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

View File

@ -0,0 +1,6 @@
{
"usingComponents": {
"list-view":"/miniprogram_npm/@beefast-wxmp/list-view"
},
"navigationBarTitleText": "我的形象照"
}

View File

@ -0,0 +1,23 @@
<!-- <view class="page">
<view class="page-head">我的形象照</view>
</view> -->
<list-view class="images-list" bind:refresh="refreshList" bind:loadMore="loadList"
refresher-triggered="{{pager.refreshTrigger}}" id="listView"
show-load-more="{{!(list.length==0&&pager.loadAll)}}"
loading="{{pager.loading}}" load-all="{{pager.loadAll}}">
<view class="item-container">
<view class="item" wx:for="{{list}}" wx:key="index" bind:longpress="deleteImage"
data-item="{{item}}">
<image class="image" src="{{item.image_url}}" mode="aspectFit"/>
<view class="default-mark" wx:if="{{item.is_default}}">默认</view>
<view class="btn-close" data-item="{{item}}" data-index="{{index}}" bind:tap="deleteImage">
<view class="icon close"></view>
</view>
<button class="btn-set-default" size="mini" type="primary" data-item="{{item}}"
data-index="{{index}}" bind:tap="setDefault" wx:if="{{!item.is_default}}">
{{autoBack?'使用该形象':'设为默认'}}
</button>
</view>
</view>
</list-view>

View File

@ -0,0 +1,50 @@
.images-list{
height:100vh;
}
.item-container{
padding:0 20rpx;
display: flex;
flex-wrap: wrap;
gap: 20rpx;
}
.images-list .item{
width:calc(50vw - 30rpx);
height:calc((50vw - 30rpx)/3*4);
border-radius: 20rpx;
overflow: hidden;
position: relative;
}
.images-list .default-mark{
position: absolute;
top:0;left:0;
background-color: var(--main-color);
color: #fff;
font-size: 24rpx;
font-weight: bold;
padding:10rpx;
border-radius: 0 0 20rpx 0;
}
.images-list .image{
width:100%;height:100%;
}
.images-list .btn-close{
width:50rpx;height:50rpx;
display: flex;
align-items: center;
justify-content: center;
position: absolute;
right:0;top:0;
border-radius: 0 0 0 20rpx;
font-size: 22rpx;
color: #777;
background-color: rgba(0, 0, 0, .1);
}
.images-list .btn-set-default{
position: absolute;
bottom:30rpx;
left:0;
font-size: 24rpx;
font-weight: bold;
left:50%;
margin-left:-3.25em;
}

View File

@ -1,4 +1,4 @@
import userAPI from '../../../api/user';
const app = getApp();
Page({
@ -27,7 +27,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
userAPI.getInfo().then((data)=>{
app.forceGetUserInfo().then((data)=>{
this.setData({
userInfo:data
})

View File

@ -1,3 +1,4 @@
{
"usingComponents": {}
"usingComponents": {},
"navigationStyle": "custom"
}

View File

@ -2,36 +2,34 @@
<view class="container">
<!-- 用户信息卡片 -->
<view class="user-card">
<image class="avatar" src="/assets/tabbar/tab3.png" mode="aspectFill"></image>
<view class="user-info">
<text class="nickname">用户昵称</text>
</view>
<image class="avatar" src="{{userInfo.avatar}}" mode="aspectFill"></image>
<view class="nickname">{{userInfo.nickname}}</view>
</view>
<!-- 功能入口区 -->
<view class="cells cells-access">
<view class="cell">
<view class="cell-hd">
<view class="icon history"></view>
</view>
<view class="cell-bd">我的收藏</view>
<navigator class="cell" url="/pages/my/images/index">
<view class="cell-bd">我的形象照</view>
<view class="cell-ft"></view>
</view>
</navigator>
<navigator class="cell" url="/pages/my/setting/index">
<view class="cell-bd">个人设置</view>
<view class="cell-ft"></view>
</navigator>
<view class="cell">
<view class="cell-hd">
<view class="icon history"></view>
</view>
<view class="cell-bd">试穿历史</view>
<view class="cell-bd">用户协议</view>
<view class="cell-ft"></view>
</view>
</view>
<button class="cells cells-access share" open-type="share">
<view class="cell">
<view class="cell-hd">
<view class="icon history"></view>
<view class="cell-bd">
<view class="title">分享给好友</view>
<view class="tips">每分享一个好友,可得<text class="count">3</text>次生成次数</view>
</view>
<view class="cell-bd">我的收藏</view>
<view class="cell-ft"></view>
</view>
</view>
</button>
</view>

View File

@ -6,32 +6,18 @@
}
/* 用户信息卡片 */
.user-card {
background: #fff;
padding: 40rpx 30rpx;
display: flex;
align-items: center;
margin-bottom: 20rpx;
.user-card{
text-align: center;
padding:220rpx 0 60rpx 0;
}
.avatar {
width: 140rpx;
height: 140rpx;
border-radius: 70rpx;
margin-right: 30rpx;
border: none;
border-radius: 50%;
vertical-align: middle;
}
.user-info {
flex: 1;
}
.nickname {
font-size: 40rpx;
font-weight: 600;
color: #FF2727;
margin-bottom: 12rpx;
display: block;
.user-card .nickname{
margin-top:40rpx;
}
.signature {
@ -40,3 +26,30 @@
display: block;
}
.share{
width:auto!important;
margin:40rpx 20rpx 20rpx 20rpx!important;
color: var(--main-font-color);
padding:0;
font-weight: normal;
line-height: 1;
}
.share .cell-bd{
flex-direction: column;
align-items:flex-start;
justify-content: center;
padding:20rpx 0;
}
.share .cell-bd .title{
font-weight: bold;
}
.share .cell-bd .tips{
font-size: 26rpx;
color: #666;
margin-top:30rpx;
}
.share .count{
color:var(--main-color);
margin:0 10rpx;
font-weight: bold;
}

View File

@ -1,4 +1,5 @@
import userAPI from '../../../api/user';
const app = getApp();
Page({
@ -8,7 +9,8 @@ Page({
*/
data: {
isAgree:false,
loging:false
loging:false,
userCode:''
},
/**
@ -34,7 +36,7 @@ Page({
wx.navigateBack({
fail(){
wx.reLaunch({
url: '/pages/closet/index/index',
url: '/pages/try/index/index',
})
}
});
@ -60,7 +62,9 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
this.setData({
userCode:app.globalData.shared_user_code||''
})
},
/**

View File

@ -11,3 +11,4 @@
</label>
</radio-group>
</view>
<view class="user-code">{{userCode}}</view>

View File

@ -37,3 +37,10 @@
.bottom .radio-group .red{
color: var(--main-color);
}
.user-code{
position: absolute;
bottom:0;
text-align: center;
width: 100%;
color: #eee;
}

114
pages/my/setting/index.js Normal file
View File

@ -0,0 +1,114 @@
import userAPI from "../../../api/user";
import commonAPI from '../../../api/common';
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
userInfo:{},
uploading:false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
chooseAvatar(event){
wx.cropImage({
cropScale: '1:1',
src: event.detail.avatarUrl,
success:()=>{
this.setData({
uploading:true
})
commonAPI.upload({tempFilePath:event.detail.avatarUrl}).then((data)=>{
return userAPI.updateInfo({avatar:data.url})
}).then(()=>{
wx.showToast({
icon:'none',
title: '头像更新成功',
})
return app.forceGetUserInfo();
}).then((data)=>{
this.setData({userInfo:data})
}).finally(()=>{
this.setData({
uploading:false
})
})
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
app.forceGetUserInfo().then((data)=>{
this.setData({
userInfo:data
})
})
},
logout(){
wx.removeStorage({
key: 'token',
success(){
app.globalData.accessToken = '';
app.globalData.userInfo = {};
wx.reLaunch({
url: '/pages/my/login/index',
})
}
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

View File

@ -0,0 +1,4 @@
{
"usingComponents": {},
"navigationBarTitleText": "设置"
}

View File

@ -0,0 +1,38 @@
<view class="page">
<view class="cells cells-access">
<button class="choose-avatar cell" open-type="chooseAvatar" bindchooseavatar="chooseAvatar">
<view class="cell-bd">修改头像</view>
<view class="cell-ft">
<view class="weui-loading" wx:if="{{uploading}}"></view>
<image src="{{userInfo.avatar}}" class="avatar"/>
</view>
</button>
<navigator url="/pages/my/setting/name/index" class="cell">
<view class="cell-bd">修改昵称</view>
<view class="cell-ft">
<view class="text">{{userInfo.nickname}}</view>
</view>
</navigator>
</view>
<view class="cells cells-access">
<view class="cell" bind:tap="navToPrivacy">
<view class="cell-bd">隐私政策</view>
<view class="cell-ft"></view>
</view>
<view class="cell" bind:tap="navToAgreement">
<view class="cell-bd">用户协议</view>
<view class="cell-ft"></view>
</view>
</view>
<button type="default" class="logout-btn" bind:tap="logout">退出登录</button>
</view>
<page-container show="{{isShowPopup}}" close-on-slide-down>
<view class="content">
<view class="input-area">
<input class="input" model:value="{{inputName}}"/>
<button type="primary" size="mini" class="button"
disabled="{{name==inputName}}" bind:tap="saveName">保存</button>
</view>
</view>
</page-container>

View File

@ -0,0 +1,48 @@
.page{
background-color: #f5f5f5;
min-height: 100vh;
padding:10rpx 0;
}
.cell .avatar{
width:80rpx;height:80rpx;
border-radius: 50%;
}
.content{
height:100vh;
overflow: hidden;
}
.input-area{
background-color: #fff;
margin-top:20rpx;
display: flex;
align-items: center;
padding:0 20rpx;
}
.input-area .input{
height:88rpx;
line-height: 88rpx;
flex: 1;
}
.cells .cell-ft .text{
color:var(--main-font-color);
}
.cells .cell-ft .weui-loading{
margin-right: 20rpx;
}
.logout-btn{
margin:40rpx 20rpx 20rpx!important;
padding:38rpx 0!important;
line-height: 1;
background-color: rgba(153, 153, 153, 0.15)!important;
font-size: 32rpx;
font-weight: normal;
color: #666666!important;
}
.choose-avatar{
background-color: transparent;
width:auto!important;
color:var(--main-font-color);
font-weight: normal;
border-radius: 0;
}

View File

@ -0,0 +1,98 @@
import userAPI from '../../../../api/user';
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
name:'',
userInfo:{},
loading:false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
app.getUserInfo().then((data)=>{
this.setData({
userInfo:data,
name:data.nickname
})
})
},
save(){
if(this.data.name==this.data.userInfo.nickname||this.data.name==''){
return;
}
if(this.data.loading)return;
this.setData({
loading:true
})
userAPI.updateInfo({nickname:this.data.name}).then((data)=>{
return app.forceGetUserInfo();
}).then((data)=>{
wx.navigateBack({
success(){
wx.showToast({
title: '更新成功',
});
}
});
}).catch(()=>{
this.setData({
loading:false
})
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

View File

@ -0,0 +1,4 @@
{
"usingComponents": {},
"navigationBarTitleText": "修改昵称"
}

View File

@ -0,0 +1,5 @@
<view class="page-container">
<input class="input" placeholder="请输入昵称" model:value="{{name}}" type="nickname"/>
</view>
<button loading="{{loading}}" type="primary" bind:tap="save" class="save-btn" disabled="{{name==userInfo.nickname||name==''}}">保存并使用</button>

View File

@ -0,0 +1,14 @@
.page-container{
height:160rpx;
display: flex;
align-items: center;
padding:0 40rpx;
}
.page-container .input{
height:100rpx;
flex: 1;
font-size: 36rpx;
}
.save-btn{
margin:40rpx 20rpx!important;
}

View File

@ -30,25 +30,37 @@ Page({
pageHeight:0,
tryonStatus:userAPI.tryOnStatus
tryonStatus:userAPI.tryOnStatus,
shared_history_id:'',
userInfo:{},
hasMultiPersonImages:false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
console.log(options);
const windowInfo = wx.getWindowInfo();
console.log(windowInfo);
const imgWidth = windowInfo.windowWidth - rpxToPx(80);
const imgHeight = imgWidth*4/3;
console.log(imgWidth,imgHeight);
this.setData({
imgHeight,
pageHeight:windowInfo.screenHeight
})
this.getDefaultPersonImage();
this.getHistory();
this.getUserInfo();
this.getPersonImages();
},
getPersonImages(){
userAPI.getPersonImages({skip:0,limit:2}).then((data)=>{
this.setData({
hasMultiPersonImages:data.length>1
})
})
},
getHistory(){
userAPI.tryonHistory().then((data)=>{
@ -82,7 +94,8 @@ Page({
"personImage.serverUrl":data.url
});
userAPI.addPersonImages(data.url).then(()=>{
return this.getDefaultPersonImage();
this.getDefaultPersonImage();
this.getPersonImages();
})
}).finally(()=>{
this.setData({
@ -244,6 +257,9 @@ Page({
url:'/pages/try/index/index',
preserveQuery:true
});
this.setData({
shared_history_id:''
})
this.options.shared_history_id = '';
},
@ -254,15 +270,25 @@ Page({
},
getUserInfo(){
userAPI.getInfo().then((data)=>{
this.setData({
userInfo:data
})
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
this.getDefaultPersonImage();
if(this.options&&this.options.shared_history_id){
userAPI.tryonDetail(this.options.shared_history_id).then((data)=>{
wx.hideTabBar({
success:()=>{
this.setData({
shared_history_id:this.options.shared_history_id,
isShowComment:true,
tryonComment:data
})
@ -271,6 +297,13 @@ Page({
})
}
},
tryonShared(){
this.setTop(this.data.tryonComment.top_clothing_url);
this.setBottom(this.data.tryonComment.bottom_clothing_url);
this.setData({
isShowComment:false
})
},
getDefaultPersonImage(){
userAPI.getDefaultPersonImage().then((data)=>{
this.setData({
@ -304,6 +337,11 @@ Page({
urls: [url],
})
},
navToPersonImage(){
wx.navigateTo({
url: '/pages/my/images/index?auto_back=true',
})
},
/**
* 生命周期函数--监听页面隐藏
*/

View File

@ -3,9 +3,14 @@
<nav-bar/>
<view class="header">
<view>我的试衣间</view>
<button plain size="mini" class="button" bind:tap="chooseImg"
<button plain size="mini" class="button" bind:tap="navToPersonImage"
wx:if="{{hasMultiPersonImages}}"
loading="{{personImage.uploading}}">
更换形象照
</button>
<button plain size="mini" class="button" bind:tap="chooseImg" wx:else
loading="{{personImage.uploading}}" disabled="{{personImage.uploading}}">
{{defaultPersonImage?'更换形象照':'添加形象照'}}
添加形象照
</button>
</view>
</view>
@ -66,8 +71,8 @@
</block>
<button type="primary" bind:tap="tryon"
loading="{{hasTryon||trying}}"
disabled="{{hasTryon||trying}}" wx:else>
{{hasTryon||trying?'请等待上一个试穿任务':'立刻试穿'}}
disabled="{{hasTryon||trying||userInfo.tryon_remain_count<1}}" wx:else>
{{hasTryon||trying?'请等待上一个试穿任务':'立刻试穿(剩余:'+userInfo.tryon_remain_count+'次)'}}
</button>
</view>
<scroll-view class="history" scroll-x="{{true}}" enable-flex show-scrollbar="{{false}}" enhanced>
@ -104,6 +109,7 @@
<view class="point">{{tryonComment.score}}</view>
<view class="cmt-title">AI 点评:</view>
<view class="cmt-content">{{tryonComment.comment}}</view>
<button class="button" type="primary" bind:tap="share" open-type="share">分享</button>
<button wx:if="{{shared_history_id}}" class="button" type="primary" bind:tap="tryonShared">试穿</button>
<button class="button" type="primary" bind:tap="share" open-type="share" wx:else>分享</button>
</view>
</modal-view>

View File

@ -8,7 +8,14 @@
"miniprogram": {
"list": [
{
"name": "pages/try/index/index",
"name": "测试分享码",
"pathName": "pages/my/login/index",
"query": "shared_user_code=ASSDJK",
"launchMode": "default",
"scene": null
},
{
"name": "测试分享穿搭",
"pathName": "pages/try/index/index",
"query": "shared_history_id=33",
"launchMode": "default",
@ -16,5 +23,6 @@
}
]
}
}
},
"libVersion": "3.7.12"
}