diff --git a/api/request.js b/api/request.js index 731d41d..5e20ad3 100644 --- a/api/request.js +++ b/api/request.js @@ -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; + } } - 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); } }, diff --git a/api/user.js b/api/user.js index 50cf473..66733b9 100644 --- a/api/user.js +++ b/api/user.js @@ -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:'已生成' diff --git a/app.js b/app.js index 0611d61..034ed84 100644 --- a/app.js +++ b/app.js @@ -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(); + } + } + }); + }); } }) diff --git a/app.json b/app.json index f627044..e2a918d 100644 --- a/app.json +++ b/app.json @@ -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", diff --git a/app.wxss b/app.wxss index 65b9ea8..b9c731a 100644 --- a/app.wxss +++ b/app.wxss @@ -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; @@ -151,4 +170,13 @@ radio .wx-radio-input.wx-radio-input-checked::before{ background-color:currentColor; 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); } \ No newline at end of file diff --git a/assets/icon.wxss b/assets/icon.wxss index e3c888d..9e6b6c6 100644 --- a/assets/icon.wxss +++ b/assets/icon.wxss @@ -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) } \ No newline at end of file diff --git a/assets/img/share.jpg b/assets/img/share.jpg new file mode 100644 index 0000000..858543e Binary files /dev/null and b/assets/img/share.jpg differ diff --git a/miniprogram_npm/@beefast-wxmp/list-view/index.js b/miniprogram_npm/@beefast-wxmp/list-view/index.js index 42e3cad..df6a619 100644 --- a/miniprogram_npm/@beefast-wxmp/list-view/index.js +++ b/miniprogram_npm/@beefast-wxmp/list-view/index.js @@ -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:{ diff --git a/miniprogram_npm/@beefast-wxmp/list-view/index.wxss b/miniprogram_npm/@beefast-wxmp/list-view/index.wxss index b83fa71..ef2a48e 100644 --- a/miniprogram_npm/@beefast-wxmp/list-view/index.wxss +++ b/miniprogram_npm/@beefast-wxmp/list-view/index.wxss @@ -1,3 +1,6 @@ +:host{ + display: block; +} .scroll-view{ height:100%; } diff --git a/pages/my/images/index.js b/pages/my/images/index.js new file mode 100644 index 0000000..172af74 --- /dev/null +++ b/pages/my/images/index.js @@ -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.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() { + + } +}) \ No newline at end of file diff --git a/pages/my/images/index.json b/pages/my/images/index.json new file mode 100644 index 0000000..721bfa2 --- /dev/null +++ b/pages/my/images/index.json @@ -0,0 +1,6 @@ +{ + "usingComponents": { + "list-view":"/miniprogram_npm/@beefast-wxmp/list-view" + }, + "navigationBarTitleText": "我的形象照" +} \ No newline at end of file diff --git a/pages/my/images/index.wxml b/pages/my/images/index.wxml new file mode 100644 index 0000000..07d3487 --- /dev/null +++ b/pages/my/images/index.wxml @@ -0,0 +1,23 @@ + + + + + + + 默认 + + + + + + + \ No newline at end of file diff --git a/pages/my/images/index.wxss b/pages/my/images/index.wxss new file mode 100644 index 0000000..36c9e2e --- /dev/null +++ b/pages/my/images/index.wxss @@ -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; +} \ No newline at end of file diff --git a/pages/my/index/index.js b/pages/my/index/index.js index 5014a65..c129fba 100644 --- a/pages/my/index/index.js +++ b/pages/my/index/index.js @@ -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 }) diff --git a/pages/my/index/index.json b/pages/my/index/index.json index 8835af0..965b8e8 100644 --- a/pages/my/index/index.json +++ b/pages/my/index/index.json @@ -1,3 +1,4 @@ { - "usingComponents": {} + "usingComponents": {}, + "navigationStyle": "custom" } \ No newline at end of file diff --git a/pages/my/index/index.wxml b/pages/my/index/index.wxml index 0a65a24..385ff12 100644 --- a/pages/my/index/index.wxml +++ b/pages/my/index/index.wxml @@ -2,36 +2,34 @@ - - + + {{userInfo.nickname}} - - - - - 我的收藏 + + 我的形象照 - + - - - - - 试穿历史 + + 个人设置 - + - - - - 我的收藏 + 用户协议 + \ No newline at end of file diff --git a/pages/my/index/index.wxss b/pages/my/index/index.wxss index ed0e428..c943a57 100644 --- a/pages/my/index/index.wxss +++ b/pages/my/index/index.wxss @@ -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; +} \ No newline at end of file diff --git a/pages/my/login/index.js b/pages/my/login/index.js index 7af90d6..0d59fc0 100644 --- a/pages/my/login/index.js +++ b/pages/my/login/index.js @@ -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||'' + }) }, /** diff --git a/pages/my/login/index.wxml b/pages/my/login/index.wxml index e470dba..8ea479c 100644 --- a/pages/my/login/index.wxml +++ b/pages/my/login/index.wxml @@ -10,4 +10,5 @@ 同意《美搭用户协议》 - \ No newline at end of file + +{{userCode}} \ No newline at end of file diff --git a/pages/my/login/index.wxss b/pages/my/login/index.wxss index bfbffe9..115c632 100644 --- a/pages/my/login/index.wxss +++ b/pages/my/login/index.wxss @@ -36,4 +36,11 @@ } .bottom .radio-group .red{ color: var(--main-color); +} +.user-code{ + position: absolute; + bottom:0; + text-align: center; + width: 100%; + color: #eee; } \ No newline at end of file diff --git a/pages/my/setting/index.js b/pages/my/setting/index.js new file mode 100644 index 0000000..385876c --- /dev/null +++ b/pages/my/setting/index.js @@ -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() { + + } +}) \ No newline at end of file diff --git a/pages/my/setting/index.json b/pages/my/setting/index.json new file mode 100644 index 0000000..e8c2c06 --- /dev/null +++ b/pages/my/setting/index.json @@ -0,0 +1,4 @@ +{ + "usingComponents": {}, + "navigationBarTitleText": "设置" +} \ No newline at end of file diff --git a/pages/my/setting/index.wxml b/pages/my/setting/index.wxml new file mode 100644 index 0000000..4ace838 --- /dev/null +++ b/pages/my/setting/index.wxml @@ -0,0 +1,38 @@ + + + + + 修改昵称 + + {{userInfo.nickname}} + + + + + + + 隐私政策 + + + + 用户协议 + + + + + + + + + + + + + \ No newline at end of file diff --git a/pages/my/setting/index.wxss b/pages/my/setting/index.wxss new file mode 100644 index 0000000..509cde0 --- /dev/null +++ b/pages/my/setting/index.wxss @@ -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; +} \ No newline at end of file diff --git a/pages/my/setting/name/index.js b/pages/my/setting/name/index.js new file mode 100644 index 0000000..0da1c9e --- /dev/null +++ b/pages/my/setting/name/index.js @@ -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() { + + } +}) \ No newline at end of file diff --git a/pages/my/setting/name/index.json b/pages/my/setting/name/index.json new file mode 100644 index 0000000..ed2289c --- /dev/null +++ b/pages/my/setting/name/index.json @@ -0,0 +1,4 @@ +{ + "usingComponents": {}, + "navigationBarTitleText": "修改昵称" +} \ No newline at end of file diff --git a/pages/my/setting/name/index.wxml b/pages/my/setting/name/index.wxml new file mode 100644 index 0000000..3b284d0 --- /dev/null +++ b/pages/my/setting/name/index.wxml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/pages/my/setting/name/index.wxss b/pages/my/setting/name/index.wxss new file mode 100644 index 0000000..e2a9adf --- /dev/null +++ b/pages/my/setting/name/index.wxss @@ -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; +} \ No newline at end of file diff --git a/pages/try/index/index.js b/pages/try/index/index.js index 3f410b6..aa63a15 100644 --- a/pages/try/index/index.js +++ b/pages/try/index/index.js @@ -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 = ''; }, @@ -253,16 +269,26 @@ Page({ onReady() { }, + + 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', + }) + }, /** * 生命周期函数--监听页面隐藏 */ diff --git a/pages/try/index/index.wxml b/pages/try/index/index.wxml index 0ad28cb..320333d 100644 --- a/pages/try/index/index.wxml +++ b/pages/try/index/index.wxml @@ -3,9 +3,14 @@ 我的试衣间 - + @@ -66,8 +71,8 @@ @@ -104,6 +109,7 @@ {{tryonComment.score}} AI 点评: {{tryonComment.comment}} - + + \ No newline at end of file diff --git a/project.private.config.json b/project.private.config.json index f602aa3..b98f2e8 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -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" } \ No newline at end of file