commit 8243ced2421fe29a28eeb8406e18fb2330278e86 Author: 潇 Date: Sun Apr 13 01:27:54 2025 +0800 first diff --git a/api/clothing.js b/api/clothing.js new file mode 100644 index 0000000..0618ce2 --- /dev/null +++ b/api/clothing.js @@ -0,0 +1,43 @@ +import request from './request'; + +const clothingAPI = { + /** + * 获取衣物列表 + * @param {object} params - 分页参数 + * @param {number} params.skip - 跳过的数量 + * @param {number} params.limit - 获取的数量 + */ + getList(params) { + return request.get('/api/v1/clothing', params); + }, + + /** + * 获取衣物详情 + * @param {string} id - 衣物ID + */ + getDetail(id) { + return request.get(`/api/v1/clothing/${id}`); + }, + + /** + * 添加衣物 + * @param {object} data - 衣物数据 + */ + create(clothing_category_id,image_url) { + return request.post('/api/v1/clothing', {clothing_category_id,image_url}); + }, + + + /** + * 删除衣物 + * @param {string} id - 衣物ID + */ + delete(id) { + return request.delete(`/api/v1/clothing/${id}`); + }, + getCategories(){ + return request.get('/api/v1/clothing/categories') + } +}; + +export default clothingAPI; \ No newline at end of file diff --git a/api/common.js b/api/common.js new file mode 100644 index 0000000..22b57ba --- /dev/null +++ b/api/common.js @@ -0,0 +1,23 @@ +import request from './request'; + +const commonAPI = { + upload(file){ + return new Promise((rs,rj)=>{ + const task = wx.uploadFile({ + filePath: file.tempFilePath, + name: 'file', + url: `${request.baseURL}/api/v1/upload`, + success:(res)=>{ + const response = JSON.parse(res.data); + rs(response.data); + }, + fail:(res)=>{ + rj(res); + } + }) + file.task = task; + }) + } +}; + +export default commonAPI; \ No newline at end of file diff --git a/api/request.js b/api/request.js new file mode 100644 index 0000000..731d41d --- /dev/null +++ b/api/request.js @@ -0,0 +1,140 @@ +// 全局API请求实例 + +class Request { + constructor() { + this.baseURL = 'https://meida-api.beefast.co'; + this.interceptors = { + request: [], + response: [] + }; + this.setupInterceptors(); + } + + setupInterceptors() { + // 添加请求拦截器 + this.addRequestInterceptor(config => { + // 在这里添加通用的请求头,如token等 + const token = wx.getStorageSync('token'); + if (token) { + config.header = { + ...config.header, + 'Authorization': `Bearer ${token}` + }; + } + return config; + }); + + // 添加响应拦截器 + this.addResponseInterceptor(response => { + // 处理通用的响应逻辑 + if (response.statusCode === 401) { + if(this.loginRoutePromise){ + throw new Error(response.data) + } + const pages = getCurrentPages(); + const currentPages = pages[pages.length-1]; + if(currentPages&¤tPages.route.indexOf('pages/my/login/index')>-1){ + throw new Error('已在登录页面'); + } + // token过期,重新登录 + this.loginRoutePromise = wx.navigateTo({ + url: '/pages/my/login/index' + }); + this.loginRoutePromise.then(()=>{ + this.loginRoutePromise = null; + }) + throw new Error(response.data) + } + return response; + }); + } + + addRequestInterceptor(interceptor) { + this.interceptors.request.push(interceptor); + } + + addResponseInterceptor(interceptor) { + this.interceptors.response.push(interceptor); + } + + async processRequestInterceptors(config) { + for (const interceptor of this.interceptors.request) { + config = await interceptor(config); + } + return config; + } + + async processResponseInterceptors(response) { + for (const interceptor of this.interceptors.response) { + response = await interceptor(response); + } + return response; + } + + async request(config) { + try { + config = await this.processRequestInterceptors(config); + const url = config.url.startsWith('http') ? config.url : `${this.baseURL}${config.url}`; + + return new Promise((resolve, reject) => { + wx.request({ + ...config, + url, + success: async (res) => { + try { + const processedResponse = await this.processResponseInterceptors(res); + resolve(processedResponse.data.data); + } catch (error) { + reject(error); + } + }, + fail: (error) => { + reject(error); + } + }); + }); + } catch (error) { + throw error; + } + } + + get(url, params, options = {}) { + return this.request({ + method: 'GET', + url, + data: params, + ...options + }); + } + + post(url, data, options = {}) { + return this.request({ + method: 'POST', + url, + data, + ...options + }); + } + + put(url, data, options = {}) { + return this.request({ + method: 'PUT', + url, + data, + ...options + }); + } + + delete(url, data, options = {}) { + return this.request({ + method: 'DELETE', + url, + data, + ...options + }); + } +} + +// 创建全局请求实例 +const request = new Request(); +export default request; \ No newline at end of file diff --git a/api/user.js b/api/user.js new file mode 100644 index 0000000..01059e7 --- /dev/null +++ b/api/user.js @@ -0,0 +1,91 @@ +import request from './request'; + +const userAPI = { + login(code){ + return request.post('/api/v1/auth/login/wechat',{code}) + }, + /** + * 获取用户信息 + */ + getInfo() { + return request.get('/api/v1/users/me'); + }, + + /** + * 更新用户信息 + * @param {object} data - 用户信息 + */ + updateInfo(data) { + return request.put('/api/v1/user/info', data); + }, + + /** + * 更新用户设置 + * @param {object} data - 设置信息 + */ + updateSettings(data) { + return request.put('/api/v1/user/settings', data); + }, + + /** + * 获取用户收藏列表 + * @param {object} params - 分页参数 + */ + getFavorites(params) { + return request.get('/api/v1/user/favorites', params); + }, + + /** + * 添加收藏 + * @param {string} itemId - 收藏项目ID + */ + addFavorite(itemId) { + return request.post('/api/v1/user/favorites', { itemId }); + }, + + /** + * 取消收藏 + * @param {string} itemId - 收藏项目ID + */ + removeFavorite(itemId) { + return request.delete(`/api/v1/user/favorites/${itemId}`); + }, + /** + * + * @param {Object} data + * @image_url + * @is_default + */ + + addPersonImages(image_url,is_default=true){ + return request.post('/api/v1/person-images',{image_url,is_default}) + }, + getPersonImages(data){ + return request.get('/api/v1/person-images',data) + }, + getDefaultPersonImage(){ + return request.get('/api/v1/person-images/default') + }, + /** + * + * @param {Object} data + * @param top_clothing_id + * @param top_clothing_url + * @param bottom_clothing_id + * @param bottom_clothing_url + */ + tryon(data){ + return request.post('/api/v1/tryon',data) + }, + checkTryon(history_id){ + return request.get(`/api/v1/tryon/history/${history_id}/check`) + }, + tryonHistory(){ + return request.get('/api/v1/tryon/histories') + }, + deleteTryon(history_id){ + return request.delete(`/api/v1/tryon/history/${history_id}`) + } +}; + +export default userAPI; \ No newline at end of file diff --git a/app.js b/app.js new file mode 100644 index 0000000..3eb1fc5 --- /dev/null +++ b/app.js @@ -0,0 +1,8 @@ +App({ + onLaunch() { +console.log(111); + }, + globalData: { + userInfo: null + } +}) diff --git a/app.json b/app.json new file mode 100644 index 0000000..6580265 --- /dev/null +++ b/app.json @@ -0,0 +1,34 @@ +{ + "pages": [ + "pages/try/index/index", + "pages/my/login/index", + "pages/closet/index/index", + "pages/my/index/index" + ], + "window": { + "navigationBarTextStyle": "black", + "navigationBarTitleText": "美搭", + "navigationBarBackgroundColor": "#ffffff" + }, + "tabBar": { + "selectedColor": "#FF2727", + "list": [ + { + "pagePath": "pages/closet/index/index", + "text": "衣橱", + "iconPath": "/assets/tabbar/tab1.png", + "selectedIconPath": "/assets/tabbar/tab1-active.png" + }, + { + "pagePath": "pages/try/index/index", + "text": "试衣间", + "iconPath": "/assets/tabbar/tab2.png", + "selectedIconPath": "/assets/tabbar/tab2-active.png" + } + ] + }, + "style": "v2", + "componentFramework": "glass-easel", + "sitemapLocation": "sitemap.json", + "lazyCodeLoading": "requiredComponents" +} \ No newline at end of file diff --git a/app.wxss b/app.wxss new file mode 100644 index 0000000..86abc4b --- /dev/null +++ b/app.wxss @@ -0,0 +1,49 @@ +@import './assets/icon.wxss'; +page{ + --main-color:#FF2727; + --main-bgclolor:#ffffff; + --safe-bottom:constant(safe-area-inset-bottom); + --safe-bottom:env(safe-area-inset-bottom); + background-color: var(--main-bgclolor); + font-size: 30rpx; + color: #333333; + line-height: 1; + height: 100vw; + overflow: hidden; +} + +button{ + border-radius: 40rpx; + background-color: #000; + color: #fff; + margin:0; + transition-duration: .4s; +} +button[type=primary]{ + background-color: #000; + width: auto; +} +button.button-hover{ + background-color: #000!important; + opacity: .8; +} +button.icon-button{ + width:60rpx;height:60rpx; + padding:0; + line-height: 1; + display: flex; + align-items: center; + justify-content: center; + font-size: 40rpx; +} + +.custom-scroll-view{ + height:100vh; + display:flex; + flex-direction: column; + box-sizing: border-box; +} +.custom-scroll-view .main{ + overflow: hidden; + flex:1; +} \ No newline at end of file diff --git a/assets/icon.wxss b/assets/icon.wxss new file mode 100644 index 0000000..47695cc --- /dev/null +++ b/assets/icon.wxss @@ -0,0 +1,80 @@ + +.icon{ + width:1em;height:1em; + -webkit-mask-position:0 0; + mask-position:0 0; + -webkit-mask-repeat:no-repeat; + mask-repeat:no-repeat; + -webkit-mask-size:100%; + mask-size:100%; + background-color:currentColor; +} +.icon.cloud{ + mask-image: var(--icon-cloud); + -webkit-mask-image:var(--icon-cloud); +} +.icon.logo{ + /* mask-image: var(--icon-logo); + -webkit-mask-image:var(--icon-logo); */ + background: var(--icon-logo) no-repeat center; + background-size: 100%; +} +.icon.share{ + mask-image: var(--icon-share); + -webkit-mask-image:var(--icon-share); +} +.icon.body{ + mask-image: var(--icon-body); + -webkit-mask-image:var(--icon-body); +} +.icon.top-clothing{ + mask-image: var(--icon-top-clothing); + -webkit-mask-image: var(--icon-top-clothing); +} +.icon.bottom-clothing{ + mask-image: var(--icon-bottom-clothing); + -webkit-mask-image: var(--icon-bottom-clothing); +} +.icon.plus{ + mask-image: var(--icon-plus); + -webkit-mask-image: var(--icon-plus); +} +.icon.loading{ + mask-image: var(--icon-loading); + -webkit-mask-image: var(--icon-loading); +} +.icon.delete{ + mask-image: var(--icon-delete); + -webkit-mask-image: var(--icon-delete); +} +.icon.warn{ + position: relative; + background-color: #fff; + border-radius: 50%; + background-size: 80%; + color:red; +} +.icon.warn .dispatch{ + width:1em;height:1em; + -webkit-mask-position:0 0; + mask-position:0 0; + -webkit-mask-repeat:no-repeat; + mask-repeat:no-repeat; + -webkit-mask-size:100%; + mask-size:100%; + background-color:currentColor; + mask-image: var(--icon-warn); + -webkit-mask-image: var(--icon-warn); +} +page{ + --icon-cloud:url(data:image/svg+xml,%3Csvg%20t%3D%221744197807215%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%227767%22%20width%3D%22128%22%20height%3D%22128%22%3E%3Cpath%20d%3D%22M518.3%20459c-3.2-4.1-9.4-4.1-12.6%200l-112%20141.7c-4.1%205.2-0.4%2012.9%206.3%2012.9h73.9V856c0%204.4%203.6%208%208%208h60c4.4%200%208-3.6%208-8V613.7H624c6.7%200%2010.4-7.7%206.3-12.9L518.3%20459z%22%20p-id%3D%227768%22%3E%3C/path%3E%3Cpath%20d%3D%22M811.4%20366.7C765.6%20245.9%20648.9%20160%20512.2%20160S258.8%20245.8%20213%20366.6C127.3%20389.1%2064%20467.2%2064%20560c0%20110.5%2089.5%20200%20199.9%20200H304c4.4%200%208-3.6%208-8v-60c0-4.4-3.6-8-8-8h-40.1c-33.7%200-65.4-13.4-89-37.7-23.5-24.2-36-56.8-34.9-90.6%200.9-26.4%209.9-51.2%2026.2-72.1%2016.7-21.3%2040.1-36.8%2066.1-43.7l37.9-9.9%2013.9-36.6c8.6-22.8%2020.6-44.1%2035.7-63.4%2014.9-19.2%2032.6-35.9%2052.4-49.9%2041.1-28.9%2089.5-44.2%20140-44.2s98.9%2015.3%20140%2044.2c19.9%2014%2037.5%2030.8%2052.4%2049.9%2015.1%2019.3%2027.1%2040.7%2035.7%2063.4l13.8%2036.5%2037.8%2010C846.1%20454.5%20884%20503.8%20884%20560c0%2033.1-12.9%2064.3-36.3%2087.7-23.4%2023.4-54.5%2036.3-87.6%2036.3H720c-4.4%200-8%203.6-8%208v60c0%204.4%203.6%208%208%208h40.1C870.5%20760%20960%20670.5%20960%20560c0-92.7-63.1-170.7-148.6-193.3z%22%20p-id%3D%227769%22%3E%3C/path%3E%3C/svg%3E); + --icon-logo:url(data:image/svg+xml,%3Csvg%20width%3D%22615%22%20height%3D%22193%22%20viewBox%3D%220%200%20615%20193%22%20fill%3D%22none%22%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%3E%3Cpath%20d%3D%22M73.1519%20193L0.826856%2019.475V0.499987H24.4769L83.6019%20144.05L122.652%2055.775H125.402V122.6L94.3269%20193H73.1519ZM0.826856%20193V61.275H3.30186L30.5269%20126.725V193H0.826856ZM139.427%20193V0.499987H169.127V193H139.427Z%22%20fill%3D%22black%22/%3E%3Cpath%20d%3D%22M191.781%20193V0.499987H291.881V29.65H221.481V82.725H266.031V112.15H221.481V163.575H291.881V193H191.781ZM313.999%20193V0.499987H343.699V193H313.999ZM410.104%20193V163.575C413.587%20163.575%20417.346%20163.392%20421.379%20163.025C425.412%20162.475%20429.171%20161.467%20432.654%20160C436.137%20158.35%20438.979%20155.875%20441.179%20152.575C443.562%20149.092%20444.754%20144.508%20444.754%20138.825V54.675C444.754%2050.6417%20443.929%2047.1583%20442.279%2044.225C440.629%2041.1083%20438.246%2038.5417%20435.129%2036.525C432.196%2034.325%20428.621%2032.675%20424.404%2031.575C420.187%2030.475%20415.421%2029.925%20410.104%2029.925V0.499987C420.187%200.499987%20429.171%201.96666%20437.054%204.9C445.121%207.64999%20451.812%2011.5%20457.129%2016.45C462.629%2021.4%20466.846%2027.175%20469.779%2033.775C472.712%2040.1917%20474.179%2047.1583%20474.179%2054.675V138.825C474.179%20150.008%20472.071%20159.175%20467.854%20166.325C463.637%20173.475%20458.229%20178.975%20451.629%20182.825C445.212%20186.675%20438.246%20189.333%20430.729%20190.8C423.396%20192.267%20416.521%20193%20410.104%20193ZM366.379%20193V0.499987H396.079V193H366.379ZM585.216%20193L578.891%20164.95H542.866L548.916%20136.35H571.191L541.216%200.499987H570.366L614.641%20193H585.216ZM493.091%20193L529.391%2031.3H533.791L545.616%2087.125L522.241%20193H493.091Z%22%20fill%3D%22%23FF2727%22/%3E%3C/svg%3E); + --icon-share:url(data:image/svg+xml,%3Csvg%20t%3D%221744276213788%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%2224747%22%20width%3D%22128%22%20height%3D%22128%22%3E%3Cpath%20d%3D%22M866.321%20112.378c34.668%200%2063.076%2027.517%2064.182%2062.167l7.397%20231.989c0.678%2021.268-16.013%2039.058-37.281%2039.737-21.268%200.678-39.058-16.013-39.737-37.281l-5.105-160.67-340.316%20335.288c-13.78%2013.576-35.193%2014.659-50.192%203.356l-4.293-3.763c-14.933-15.158-14.751-39.552%200.407-54.486l344.358-339.319-163.206%200.037c-19.506%200-35.625-14.494-38.176-33.3l-0.352-5.228c0-21.278%2017.25-38.528%2038.528-38.528h223.786zM459.592%2064.283c21.124-2.556%2040.322%2012.496%2042.878%2033.621%202.556%2021.124-12.496%2040.321-33.621%2042.877C283.01%20163.27%20141.667%20321.648%20141.667%20510.503c0%20205.693%20166.747%20372.44%20372.44%20372.44%20185.739%200%20342.395-136.817%20368.614-318.819%203.034-21.061%2022.567-35.675%2043.628-32.641s35.675%2022.567%2032.641%2043.628C927.328%20794.905%20738.292%20960%20514.107%20960%20265.857%20960%2064.61%20758.753%2064.61%20510.503c0.001-227.945%20170.561-419.063%20394.982-446.22z%22%20p-id%3D%2224748%22%3E%3C/path%3E%3C/svg%3E); + --icon-body:url(data:image/svg+xml,%3Csvg%20t%3D%221744282866863%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%2225936%22%20width%3D%221024%22%20height%3D%221024%22%3E%3Cpath%20d%3D%22M490.237305%20165.122695c-0.053895-3.249853-3.826526-8.418358-11.307116-15.505516-11.215495-10.628042-14.772547-39.655747-14.772547-49.216674s-5.696674-55.554695%2042.09179-57.225431c47.783074-1.670737%2049.583158%2031.258947%2049.583157%2055.0912%200%204.160674-3.740295%2032.121263-10.811284%2046.295579-4.489432%209.000421-14.265937%2014.767158-13.824%2020.560842%200.269474%203.486989%203.853474%207.836295%2010.75739%2013.053305%2019.402105%2010.563368%2032.633263%2015.845053%2039.693473%2015.845053%2010.584926%200%2051.857516%2010.816674%2058.637474%2043.595452%204.527158%2021.854316%2013.069474%2070.7584%2025.637726%20146.717642%2017.014568%2038.211368%2025.519158%2066.926484%2025.519158%2086.156127%200%2019.229642%202.926484%2037.634695%208.774063%2055.204379%2020.420716%2018.846989%2030.628379%2030.946358%2030.628379%2036.298105%200%208.030316-16.157642-7.712337-16.157642-7.712337s-3.977432%2015.516295%200%2022.269305c3.982821%206.7584%206.483537%2014.190484%203.050442%2017.688253-2.285137%202.328253-7.582989%203.934316-15.893557%204.80741l-20.442274-4.80741c-3.061221-23.481937-4.106779-38.744926-3.147453-45.783579%201.444379-10.563368%202.145011-7.345853%200-12.476632-2.139621-5.125389-38.238316-98.239326-42.361263-108.630231-2.754021-6.925474-11.350232-38.065853-25.79941-93.410358-12.708379%2071.168-15.882779%20120.918232-9.52859%20149.256084%209.528589%2042.501389-8.100379%20208.001347-8.100379%20224.611705v89.8048c0%2019.676968-6.709895%2068.909811-20.124295%20147.693137%2017.752926%2017.478063%2030.337347%2026.2144%2037.753264%2026.2144%2011.129263%200%2020.248253-0.145516%2020.248252%206.618274%200%204.516379-4.473263%206.639832-13.419789%206.381137-24.716126-1.800084-40.545011-2.700126-47.481263-2.700127-10.407074%200-18.000842%203.675621-22.743579%200-4.742737-3.681011-9.490863-7.491368-4.742737-14.621642%204.742737-7.135663%204.742737-18.755368%204.742737-26.699452%200-7.944084-20.496168-111.416589-15.500127-164.5568%204.996042-53.140211%203.740295-50.849684%200-83.838653-3.740295-32.994358-10.493305-124.416-10.493305-137.819621%200-13.403621-0.032337-23.066947-5.146947-23.066947-5.12%200-7.545263%206.602105-6.327242%2017.240926%201.212632%2010.633432-9.539368%20130.182737-14.265937%20147.903326-4.726568%2017.720589%204.246905%2076.142484%204.246905%2096.697937s-16.470232%20143.699537-16.470232%20152.247242c0%208.542316%206.672168%2033.808168%200%2036.513684-6.666779%202.700126-16.346274-7.356632-22.501052-3.68101-6.154779%203.681011-34.767495%203.681011-41.703748%203.68101h-19.741642c-7.518316-3.982821-5.281684-7.415916%206.715284-10.293894%2017.990063-4.327747%2052.224-17.968505%2052.224-26.21979%200-8.256674-17.607411-117.587537-17.60741-147.693137v-89.8048c0-21.735747-17.300211-112.160337-14.416842-150.619621%202.888758-38.459284%205.524211-103.359326%202.75941-134.823073-2.759411-31.469137-3.589389-82.221811-6.7584-88.425095-3.1744-6.197895-29.561263%2099.629811-38.227536%20118.088758-5.772126%2012.309558-16.604968%2038.7072-32.498527%2079.187537%200.862316%2042.016337-0.172463%2063.024505-3.098947%2063.024505-4.387032%200-17.580463%204.807411-22.921432%204.80741-3.557053%200-8.741726-1.606063-15.554021-4.80741%207.044042-22.765137%209.216-35.112421%206.521263-37.052632-4.042105-2.910316-11.242442%209.620211-17.91461%204.807411-6.677558-4.807411%209.410021-14.821053%2015.300716-20.415326%203.923537-3.734905%208.633937-9.027368%2014.12581-15.882779%203.411537-50.989811%208.192-83.773979%2014.330611-98.347116%209.210611-21.859705%2025.114947-52.622821%2025.114947-83.887158%200-31.258947%2019.962611-125.828042%2035.807663-134.833853%2015.845053-9.000421%2072.547705-22.263916%2080.044463-30.450526%205.001432-5.459537%207.496758-9.808842%207.496758-13.053305z%22%20fill%3D%22%23D8D8D8%22%20p-id%3D%2225937%22%3E%3C/path%3E%3C/svg%3E); + --icon-top-clothing:url(data:image/svg+xml,%3Csvg%20t%3D%221744350717805%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%2228071%22%20width%3D%22128%22%20height%3D%22128%22%3E%3Cpath%20d%3D%22M682.646182%20878.121835%20341.353818%20878.121835c-46.4941%200-84.324476-45.554575-84.324476-101.542018L257.029342%20514.939119l-29.25174%2029.225741L73.709611%20390.317865l248.781608-206.736959c15.944751-11.42912%2034.072274-21.064278%2057.469412-30.63562l4.928077-2.014957%203.429563%204.07364c31.113064%2036.945213%2076.145287%2058.137125%20123.538731%2058.137125%2047.342628%200%2092.354759-21.193094%20123.503278-58.137125l3.422473-4.06655%204.920986%202.007866c23.432592%209.564251%2041.553024%2019.191137%2057.034512%2030.322445l0.399446%200.306084L950.290389%20390.275321%20796.259034%20544.129406l-29.287194-29.190287L766.97184%20776.579817C766.97184%20832.567261%20729.141464%20878.121835%20682.646182%20878.121835zM271.632758%20479.702779%20271.632758%20776.579817c0%2047.947706%2031.277334%2086.957511%2069.72106%2086.957511l341.293546%200c38.443726%200%2069.72106-39.009805%2069.72106-86.957511L752.368424%20479.774868l43.877611%2043.731068%20132.395088-132.234364L692.002437%20194.960391c-13.413351-9.613886-29.087471-18.102705-48.997138-26.512344-33.750826%2037.742923-81.251814%2059.277555-131.147115%2059.277555-49.953208%200-97.460105-21.534632-131.190841-59.270464-19.995938%208.460456-35.740966%2016.99182-49.254769%2026.655341L95.352968%20391.299935l132.423451%20132.241455L271.632758%20479.702779z%22%20fill%3D%22%23262535%22%20p-id%3D%2228072%22%3E%3C/path%3E%3C/svg%3E); + --icon-bottom-clothing:url(data:image/svg+xml,%3Csvg%20t%3D%221744351258259%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%2243102%22%20width%3D%22128%22%20height%3D%22128%22%3E%3Cpath%20d%3D%22M742.903444%20880.551602l-176.536239%200c-16.97882%200-31.952137-13.25499-35.596787-31.514874l-21.598449-254.12804-17.052091%20250.365211c-3.76992%2019.129683-18.744419%2032.384674-35.723239%2032.384674l-176.536239%200c-21.040643%200-35.736239-14.695596-35.736239-35.736239%204.799261-393.527615%2013.592983-593.699714%2017.151362-661.501542l0.212723-4.241455c0-17.382993%2016.699917-32.729757%2035.736239-32.729757l428.314874%200c19.003231%200%2035.675967%2015.292401%2035.736239%2032.748666l0.212723%204.195365c3.557197%2067.834918%2012.359191%20268.3651%2017.157271%20664.335481C778.645591%20865.856006%20763.949995%20880.551602%20742.903444%20880.551602zM515.199114%20505.27678l29.005927%20341.854898c2.276133%2011.170307%2011.641843%2019.825759%2022.162164%2019.825759l176.536239%200c13.660345%200%2022.149164-8.488819%2022.149164-22.149164-4.799261-395.638297-13.587074-595.949848-17.138362-663.705586-0.159542-2.973391-0.232813-4.559357-0.232813-4.812261%200-11.017856-11.689115-19.249044-22.142074-19.249044L297.224485%20157.041381c-10.454141%200-22.142074%208.230006-22.142074%2019.249044%200%200.258813-0.073271%201.85187-0.232813%204.845351-3.551288%2067.715557-12.339101%20267.669024-17.131271%20660.864555%200%2013.579983%208.48291%2022.062894%2022.142074%2022.062894l176.536239%200c10.520321%200%2019.89194-8.655452%2022.275616-20.589198l22.971692-338.084978L515.199114%20505.27678z%22%20p-id%3D%2243103%22%3E%3C/path%3E%3C/svg%3E); + --icon-plus:url(data:image/svg+xml,%3Csvg%20t%3D%221744381143353%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%2244078%22%20width%3D%22128%22%20height%3D%22128%22%3E%3Cpath%20d%3D%22M512%201024a58.336%2058.336%200%200%201-58.368-58.368V58.368a58.336%2058.336%200%201%201%20116.736%200v907.264c0%2031.744-25.6%2058.368-58.368%2058.368z%20m453.632-453.632H58.368a58.336%2058.336%200%201%201%200-116.736h907.264a58.336%2058.336%200%201%201%200%20116.736z%22%20p-id%3D%2244079%22%3E%3C/path%3E%3C/svg%3E); + --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) +} \ No newline at end of file diff --git a/assets/tabbar/tab1-active.png b/assets/tabbar/tab1-active.png new file mode 100644 index 0000000..9cf700c Binary files /dev/null and b/assets/tabbar/tab1-active.png differ diff --git a/assets/tabbar/tab1.png b/assets/tabbar/tab1.png new file mode 100644 index 0000000..d7480c2 Binary files /dev/null and b/assets/tabbar/tab1.png differ diff --git a/assets/tabbar/tab2-active.png b/assets/tabbar/tab2-active.png new file mode 100644 index 0000000..cd4ba9e Binary files /dev/null and b/assets/tabbar/tab2-active.png differ diff --git a/assets/tabbar/tab2.png b/assets/tabbar/tab2.png new file mode 100644 index 0000000..19df5ea Binary files /dev/null and b/assets/tabbar/tab2.png differ diff --git a/assets/tabbar/tab3-active.png b/assets/tabbar/tab3-active.png new file mode 100644 index 0000000..a383bd0 Binary files /dev/null and b/assets/tabbar/tab3-active.png differ diff --git a/assets/tabbar/tab3.png b/assets/tabbar/tab3.png new file mode 100644 index 0000000..e06a03b Binary files /dev/null and b/assets/tabbar/tab3.png differ diff --git a/miniprogram_npm/@beefast-wxmp/img-uploader/index.js b/miniprogram_npm/@beefast-wxmp/img-uploader/index.js new file mode 100644 index 0000000..fa6b5d4 --- /dev/null +++ b/miniprogram_npm/@beefast-wxmp/img-uploader/index.js @@ -0,0 +1,125 @@ +Component({ + + /** + * 组件的属性列表 + */ + properties: { + loading:{ + type:Boolean, + value:false + }, + maxImgCount:{ + type:Number, + value:10 + }, + /** + * url:上传地址 + * header:{} + */ + options:Object + }, + + /** + * 组件的初始数据 + */ + data: { + tempImgs:[] + }, + + /** + * 组件的方法列表 + */ + methods: { + chooseImage(){ + wx.chooseMedia({ + count:this.properties.maxImgCount - this.data.tempImgs.length, + mediaType:['image'], + sourceType:['camera'], + success:(res)=>{ + this.setData({ + tempImgs:this.data.tempImgs.concat(res.tempFiles) + }); + this.triggerEvent('imgChange',this.data.tempImgs); + this.uploadImages(); + } + }); + }, + async uploadImages(){ + let imgIndex = -1; + const file = this.data.tempImgs.find((item,index)=>{ + imgIndex = index; + return !item.uploaded; + }); + if(!file){ + this.setData({ + loading:false + }) + return; + } + this.setData({ + loading:true + }) + const task = wx.uploadFile({ + filePath: file.tempFilePath, + name: 'file', + header:this.properties.options.header||{}, + url: this.properties.options.url, + success:(res)=>{ + const response = JSON.parse(res.data); + this.setData({ + [`tempImgs[${imgIndex}].uploaded`]:true, + [`tempImgs[${imgIndex}].serverUrl`]:response.data.url + }) + this.uploadImages(); + }, + fail:(res)=>{ + this.setData({ + loading:false + }) + wx.showToast({ + icon:'error', + title: '上传失败', + }) + } + }); + file.task = task; + task.onProgressUpdate((res)=>{ + this.setData({ + [`tempImgs[${imgIndex}].progress`]:res.progress + }) + }) + }, + removeImage(event){ + const index = event.currentTarget.dataset.index; + if(this.data.tempImgs[index].task){ + this.data.tempImgs[index].task.abort(); + } + this.data.tempImgs.splice(index,1); + this.setData({ + tempImgs:this.data.tempImgs + }); + this.triggerEvent('imgChange',this.data.tempImgs); + }, + async getUploadedUrl(){ + await this.uploadImages(); + let urls = [],loadAll = true; + this.data.tempImgs.map((item)=>{ + if(!item.uploaded)loadAll = false; + urls.push(item.serverUrl); + }) + if(loadAll){ + return urls + } + throw new Error('图片上传失败'); + }, + setUploadedImgs(imgs){ + this.setData({ + tempImgs:imgs + }) + } + }, + lifetimes:{ + attached(){ + } + } +}) \ No newline at end of file diff --git a/miniprogram_npm/@beefast-wxmp/img-uploader/index.json b/miniprogram_npm/@beefast-wxmp/img-uploader/index.json new file mode 100644 index 0000000..6616525 --- /dev/null +++ b/miniprogram_npm/@beefast-wxmp/img-uploader/index.json @@ -0,0 +1,4 @@ +{ + "component": true, + "styleIsolation": "apply-shared" +} \ No newline at end of file diff --git a/miniprogram_npm/@beefast-wxmp/img-uploader/index.wxml b/miniprogram_npm/@beefast-wxmp/img-uploader/index.wxml new file mode 100644 index 0000000..1766e31 --- /dev/null +++ b/miniprogram_npm/@beefast-wxmp/img-uploader/index.wxml @@ -0,0 +1,13 @@ + + + + + + + + + + + 点击拍照 + + \ No newline at end of file diff --git a/miniprogram_npm/@beefast-wxmp/img-uploader/index.wxss b/miniprogram_npm/@beefast-wxmp/img-uploader/index.wxss new file mode 100644 index 0000000..3755b5b --- /dev/null +++ b/miniprogram_npm/@beefast-wxmp/img-uploader/index.wxss @@ -0,0 +1,68 @@ +.img-area{ + display: flex; + flex-wrap: wrap; + gap: 16rpx; + display: flex; + justify-content: flex-end; +} +.img-area .item{ + width: 100rpx;height:100rpx; + display: flex; + align-items: center; + justify-content: center; + flex-direction: column; + border-radius: 12rpx; + position: relative; + overflow: visible; +} + +.img-area .item .progress{ + position: absolute; + top:0;left:0; + width:100%; + z-index: 1; +} +.img-area .item .close-area{ + position: absolute; + right:-16rpx;top:-16rpx; + z-index: 2; + padding:5rpx; + display: flex; + align-items: center; + overflow: visible; +} +.img-area .item .close-area .icon{ + width:28rpx;height:28rpx; + border-radius: 50%; + background-color: rgba(153, 153, 153, 0.8); + -webkit-mask:url("data:image/svg+xml,%3C%3Fxml%20version%3D%221.0%22%20standalone%3D%22no%22%3F%3E%3C%21DOCTYPE%20svg%20PUBLIC%20%22-//W3C//DTD%20SVG%201.1//EN%22%20%22http%3A//www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd%22%3E%3Csvg%20t%3D%221741949551743%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%2225816%22%20xmlns%3Axlink%3D%22http%3A//www.w3.org/1999/xlink%22%20width%3D%22128%22%20height%3D%22128%22%3E%3Cpath%20d%3D%22M512%20992A480.512%20480.512%200%200%201%2032%20512%20480.512%20480.512%200%200%201%20512%2032a480.512%20480.512%200%200%201%20480%20480%20480.512%20480.512%200%200%201-480%20480z%20m0-434.624l135.68%20135.68a32%2032%200%200%200%2022.72%209.344%2032%2032%200%200%200%2022.528-9.344%2032%2032%200%200%200%209.344-22.592%2032%2032%200%200%200-9.344-22.656L557.184%20511.936l135.744-135.68a32%2032%200%200%200%209.472-22.784%2031.488%2031.488%200%200%200-9.472-22.464%2031.552%2031.552%200%200%200-22.656-9.472%2031.552%2031.552%200%200%200-22.656%209.472L511.936%20466.88%20376.064%20331.008a31.552%2031.552%200%200%200-22.656-9.472%2031.488%2031.488%200%200%200-22.592%209.472%2032%2032%200%200%200%200%2045.248l135.872%20135.68-135.872%20135.872a31.168%2031.168%200%200%200-9.344%2022.464%2031.616%2031.616%200%200%200%209.344%2022.72%2032%2032%200%200%200%2022.656%209.344A32%2032%200%200%200%20376%20692.992l135.872-135.68z%22%20p-id%3D%2225817%22%3E%3C/path%3E%3C/svg%3E") center/contain no-repeat; + background-position:center; + background-size:contain; + background-repeat: no-repeat; + /* center/contain no-repeat */ +} +.img-area .item.loading::after{ + content: ''; + position: absolute; + width:100%;height:100%; + left:0;top:0; + background-color: rgba(0, 0, 0, 0.3); + z-index: 0; +} +.img-area .item .image{ + width:100%;height:100%; + border-radius: 12rpx; +} + + +.img-area .take-photo{ + font-size: 20rpx; + color: rgba(153, 153, 153, 0.5); + border: 1.2px solid rgba(124, 134, 149, 0.3); +} +.img-area .take-photo .icon{ + width:32rpx;height:32rpx; + margin-bottom:14rpx; + background-color: currentColor; + -webkit-mask: url(data:image/svg+xml,%3C%3Fxml%20version%3D%221.0%22%20standalone%3D%22no%22%3F%3E%3C%21DOCTYPE%20svg%20PUBLIC%20%22-//W3C//DTD%20SVG%201.1//EN%22%20%22http%3A//www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd%22%3E%3Csvg%20t%3D%221741940716303%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%2214235%22%20xmlns%3Axlink%3D%22http%3A//www.w3.org/1999/xlink%22%20width%3D%22128%22%20height%3D%22128%22%3E%3Cpath%20d%3D%22M480%20352c-105.888%200-192%2086.112-192%20192s86.112%20192%20192%20192%20192-86.112%20192-192S585.888%20352%20480%20352zM480%20672c-70.592%200-128-57.408-128-128%200-70.592%2057.408-128%20128-128%2070.592%200%20128%2057.408%20128%20128C608%20614.592%20550.592%20672%20480%20672z%22%20fill%3D%22%235E6570%22%20p-id%3D%2214236%22%3E%3C/path%3E%3Cpath%20d%3D%22M576%20832%20160%20832c-17.632%200-32-14.336-32-32L128%20288c0-17.632%2014.368-32%2032-32l96%200c17.664%200%2032-14.336%2032-32S273.664%20192%20256%20192L160%20192C107.072%20192%2064%20235.072%2064%20288l0%20512c0%2052.928%2043.072%2096%2096%2096l416%200c17.696%200%2032-14.304%2032-32S593.696%20832%20576%20832z%22%20fill%3D%22%235E6570%22%20p-id%3D%2214237%22%3E%3C/path%3E%3Cpath%20d%3D%22M512%20256l320%200c17.664%200%2032%2014.368%2032%2032l0%20256c0%2017.696%2014.304%2032%2032%2032s32-14.304%2032-32L928%20288c0-52.928-43.072-96-96-96L512%20192c-17.664%200-32%2014.336-32%2032S494.336%20256%20512%20256z%22%20fill%3D%22%235E6570%22%20p-id%3D%2214238%22%3E%3C/path%3E%3Cpath%20d%3D%22M784%20336m-48%200a1.5%201.5%200%201%200%2096%200%201.5%201.5%200%201%200-96%200Z%22%20fill%3D%22%235E6570%22%20p-id%3D%2214239%22%3E%3C/path%3E%3Cpath%20d%3D%22M320%20160l128%200c17.696%200%2032-14.304%2032-32s-14.304-32-32-32l-128%200C302.304%2096%20288%20110.304%20288%20128S302.304%20160%20320%20160z%22%20fill%3D%22%235E6570%22%20p-id%3D%2214240%22%3E%3C/path%3E%3Cpath%20d%3D%22M960%20768l-96%200%200-96c0-17.696-14.304-32-32-32s-32%2014.304-32%2032l0%2096-96%200c-17.696%200-32%2014.304-32%2032s14.304%2032%2032%2032l96%200%200%2096c0%2017.696%2014.304%2032%2032%2032s32-14.304%2032-32l0-96%2096%200c17.696%200%2032-14.304%2032-32S977.696%20768%20960%20768z%22%20fill%3D%22%235E6570%22%20p-id%3D%2214241%22%3E%3C/path%3E%3C/svg%3E) center/contain no-repeat; +} \ No newline at end of file diff --git a/miniprogram_npm/@beefast-wxmp/list-view/index.js b/miniprogram_npm/@beefast-wxmp/list-view/index.js new file mode 100644 index 0000000..42e3cad --- /dev/null +++ b/miniprogram_npm/@beefast-wxmp/list-view/index.js @@ -0,0 +1,75 @@ +// components/listView/index.js +Component({ + + /** + * 组件的属性列表 + */ + properties: { + refresherTriggered:{ + type:Boolean, + value:false + }, + height:{ + type:Number, + value:0 + }, + loadMoreText:{ + type:String, + value:'已经到底了' + }, + showLoadMore:{ + type:Boolean, + value:true + }, + loadAll:{ + type:Boolean, + value:false + } + }, + + /** + * 组件的初始数据 + */ + data: { + heightStyle:'', + scrollHeight:0 + }, + lifetimes:{ + attached(){ + this.createSelectorQuery().select('#scrollView').boundingClientRect((res)=>{ + this.data.scrollHeight = res.height; + }).exec(); + const windowInfo = wx.getWindowInfo(); + } + }, + /** + * 组件的方法列表 + */ + methods: { + refreshList(){ + this.triggerEvent('refresh'); + }, + scrolling(event){ + //scrollTop scrollHeight + const bottomHeight = event.detail.scrollHeight-event.detail.scrollTop-this.data.scrollHeight; + if(bottomHeight<100){ + this.triggerEvent('loadMore'); + } + } + }, + observers:{ + height(h){ + let heightStyle = ''; + if(h){ + if(typeof h == 'string'){ + heightStyle = `height:${h}` + }else{ + heightStyle = `height:${this.properties.height*2}rpx` + } + this.setData({ + heightStyle:heightStyle + }) + } + } + } +}) \ No newline at end of file diff --git a/miniprogram_npm/@beefast-wxmp/list-view/index.json b/miniprogram_npm/@beefast-wxmp/list-view/index.json new file mode 100644 index 0000000..8b37bbf --- /dev/null +++ b/miniprogram_npm/@beefast-wxmp/list-view/index.json @@ -0,0 +1,5 @@ +{ + "component": true, + "usingComponents": {}, + "styleIsolation": "apply-shared" +} \ No newline at end of file diff --git a/miniprogram_npm/@beefast-wxmp/list-view/index.wxml b/miniprogram_npm/@beefast-wxmp/list-view/index.wxml new file mode 100644 index 0000000..3332b05 --- /dev/null +++ b/miniprogram_npm/@beefast-wxmp/list-view/index.wxml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/miniprogram_npm/@beefast-wxmp/list-view/index.wxss b/miniprogram_npm/@beefast-wxmp/list-view/index.wxss new file mode 100644 index 0000000..b83fa71 --- /dev/null +++ b/miniprogram_npm/@beefast-wxmp/list-view/index.wxss @@ -0,0 +1,24 @@ +.scroll-view{ + height:100%; +} +.load-more{ + padding:56rpx 0 80rpx 0; + text-align: center; + color: #888888; + font-size:24rpx; + position: relative; + width:80%; + margin:0 auto; +} +.load-more .text{ + background-color: var(--main-bgclolor); + padding:0 30rpx; +} +.load-more::before{ + content: ''; + position: absolute; + left:0;top:68rpx; + width:100%;height:1rpx; + background-color: rgba(136, 136, 136, 0.25); + z-index: -1; +} \ No newline at end of file diff --git a/miniprogram_npm/@beefast-wxmp/nav-bar/index.js b/miniprogram_npm/@beefast-wxmp/nav-bar/index.js new file mode 100644 index 0000000..2a7919a --- /dev/null +++ b/miniprogram_npm/@beefast-wxmp/nav-bar/index.js @@ -0,0 +1,68 @@ +// components/navBar.js +Component({ + options:{ + multipleSlots:true + }, + + /** + * 组件的属性列表 + */ + properties:{ + back:{ + type:Boolean, + value:false + }, + backTitle:{ + type:String, + value:'' + }, + background:{ + type:String, + value:'' + }, + homeUrl:String + }, + + /** + * 组件的初始数据 + */ + data: { + statusBarHeight:0, + navBarHeight:44, + canBack:true + }, + lifetimes:{ + attached(){ + const windowInfo = wx.getWindowInfo(); + this.setData({ + statusBarHeight:windowInfo.statusBarHeight + }); + const pages = getCurrentPages(); + if(pages.length>1){ + this.setData({ + canBack:true + }) + }else{ + this.setData({ + canBack:false + }) + } + } + }, + /** + * 组件的方法列表 + */ + methods: { + back(){ + wx.navigateBack(); + }, + backHome(){ + wx.reLaunch({ + url: this.properties.homeUrl, + }) + }, + getHeight(){ + return this.data.statusBarHeight + this.data.navBarHeight; + } + } +}) \ No newline at end of file diff --git a/miniprogram_npm/@beefast-wxmp/nav-bar/index.json b/miniprogram_npm/@beefast-wxmp/nav-bar/index.json new file mode 100644 index 0000000..8b37bbf --- /dev/null +++ b/miniprogram_npm/@beefast-wxmp/nav-bar/index.json @@ -0,0 +1,5 @@ +{ + "component": true, + "usingComponents": {}, + "styleIsolation": "apply-shared" +} \ No newline at end of file diff --git a/miniprogram_npm/@beefast-wxmp/nav-bar/index.wxml b/miniprogram_npm/@beefast-wxmp/nav-bar/index.wxml new file mode 100644 index 0000000..f6c910d --- /dev/null +++ b/miniprogram_npm/@beefast-wxmp/nav-bar/index.wxml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + {{backTitle}} + + + + + + + + \ No newline at end of file diff --git a/miniprogram_npm/@beefast-wxmp/nav-bar/index.wxss b/miniprogram_npm/@beefast-wxmp/nav-bar/index.wxss new file mode 100644 index 0000000..8eda36e --- /dev/null +++ b/miniprogram_npm/@beefast-wxmp/nav-bar/index.wxss @@ -0,0 +1,83 @@ +/* components/navBar.wxss */ +.nav-bar{ + transition-duration: .4s; + overflow: hidden; +} +.nav-bar .title{ + font-size: 36rpx; + font-weight: 600; + color:#222222; +} +.nav-bar-content{ + display: flex; + align-items: center; + justify-content: space-between; + padding:0 34rpx; +} +.nav-bar-content .left{ + flex:1; + display: flex; + align-items: center; + text-overflow: ellipsis; + max-width: calc(100vw - 140rpx); +} +.nav-bar-content .left .btns{ + display: inline-flex; + align-items: center; + border-radius: 60rpx; + vertical-align: middle; +} +.nav-bar-content .left .spliter{ + width:1.2rpx;height:36rpx; + background-color:#D8D8D8; +} +/*单一一个返回或者加上 backTitle的时候*/ +.nav-bar-content .back{ + font-size:40rpx; +} +.nav-bar-content .round{ + width:56rpx;height:56rpx; + border:1.2px solid rgba(255, 255, 255,.6); + box-sizing: border-box; + background-color: rgba(255, 255, 255, 0.3); + border-radius: 50%; + display: flex; + align-items: center; + justify-content: center; +} +.nav-bar-content .back-title{ + font-size: 36rpx; + font-weight: 600; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} +.nav-bar-content .center{ + flex:1; + text-align: center; +} +.nav-bar-content .right{flex:1;} + + +.nav-bar-content .back,.nav-bar-content .round .icon{ + width:1em;height:1em; + -webkit-mask-position:0 0; + mask-position:0 0; + -webkit-mask-repeat:no-repeat; + mask-repeat:no-repeat; + -webkit-mask-size:100%; + mask-size:100%; + background-color:currentColor; + -webkit-mask-image:var(--back-image); + mask-image: var(--back-image); +} +.nav-bar-content .round .icon{ + font-size: 40rpx; + mask-image: var(--back-home); + -webkit-mask-image: var(--back-home); +} + +page{ + --back-image:url(data:image/svg+xml,%3Csvg%20t%3D%221743422723228%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%2220325%22%20data-spm-anchor-id%3D%22a313x.search_index.0.i15.389b3a81Rr8Znb%22%20width%3D%22128%22%20height%3D%22128%22%3E%3Cpath%20d%3D%22M395.21518%20513.604544l323.135538-312.373427c19.052938-18.416442%2019.052938-48.273447%200-66.660212-19.053961-18.416442-49.910737-18.416442-68.964698%200L291.75176%20480.290811c-19.052938%2018.416442-19.052938%2048.273447%200%2066.660212l357.633237%20345.688183c9.525957%209.207709%2022.01234%2013.796214%2034.497699%2013.796214%2012.485359%200%2024.971741-4.588505%2034.466999-13.82896%2019.052938-18.416442%2019.052938-48.242747%200-66.660212L395.21518%20513.604544z%22%20fill%3D%22%23272636%22%20p-id%3D%2220326%22%3E%3C/path%3E%3C/svg%3E); + --back-home:url(data:image/svg+xml,%3Csvg%20t%3D%221743420332728%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%2216725%22%20width%3D%22128%22%20height%3D%22128%22%3E%3Cpath%20d%3D%22M946.5%20505L560.1%20118.8l-25.9-25.9c-12.3-12.2-32.1-12.2-44.4%200L77.5%20505c-12.3%2012.3-18.9%2028.6-18.8%2046%200.4%2035.2%2029.7%2063.3%2064.9%2063.3h42.5V940h691.8V614.3h43.4c17.1%200%2033.2-6.7%2045.3-18.8%2012.1-12.1%2018.7-28.2%2018.7-45.3%200-17-6.7-33.1-18.8-45.2zM568%20868H456V664h112v204z%20m217.9-325.7V868H632V640c0-22.1-17.9-40-40-40H432c-22.1%200-40%2017.9-40%2040v228H238.1V542.3h-96l370-369.7%2023.1%2023.1L882%20542.3h-96.1z%22%20p-id%3D%2216726%22%3E%3C/path%3E%3C/svg%3E) +} \ No newline at end of file diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json new file mode 100644 index 0000000..eafb088 --- /dev/null +++ b/node_modules/.package-lock.json @@ -0,0 +1,26 @@ +{ + "name": "meida", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "node_modules/@beefast-wxmp/img-uploader": { + "version": "0.1.6", + "resolved": "https://packages.aliyun.com/6486fc420ce788fc1c0798b3/npm/repo-glpby/@beefast-wxmp/img-uploader/-/@beefast-wxmp/img-uploader-0.1.6.tgz", + "integrity": "sha512-B4gltxYEDLZULpNDav8y7RtfFwSBgdLQgIb+9F6JWlLCPfZJHMe1AfIn1bQ1GftCPwNNr8l5EeTNip1kCfl1GQ==", + "license": "ISC" + }, + "node_modules/@beefast-wxmp/list-view": { + "version": "0.0.1", + "resolved": "https://packages.aliyun.com/6486fc420ce788fc1c0798b3/npm/repo-glpby/@beefast-wxmp/list-view/-/@beefast-wxmp/list-view-0.0.1.tgz", + "integrity": "sha512-XoTaXRqy8EuuHECGS2zFzAeDKoGDtC56VdahnVYTAcDLNo3fceQuXI2KhOSvjnn4Jbkt1UDch7IEuF9Eekf9eg==", + "license": "ISC" + }, + "node_modules/@beefast-wxmp/nav-bar": { + "version": "0.0.3", + "resolved": "https://packages.aliyun.com/6486fc420ce788fc1c0798b3/npm/repo-glpby/@beefast-wxmp/nav-bar/-/@beefast-wxmp/nav-bar-0.0.3.tgz", + "integrity": "sha512-h0CC32cTYguLhH+cap2LAUV7jeB6k6x6gWS3YUjkfYy6+v9XP3ohTAnuWsEDnWjJ+mJlARxdhwy8Phnl/Nuw2A==", + "license": "ISC" + } + } +} diff --git a/node_modules/@beefast-wxmp/img-uploader/package.json b/node_modules/@beefast-wxmp/img-uploader/package.json new file mode 100644 index 0000000..a1f0596 --- /dev/null +++ b/node_modules/@beefast-wxmp/img-uploader/package.json @@ -0,0 +1,17 @@ +{ + "name": "@beefast-wxmp/img-uploader", + "version": "0.1.6", + "description": "多文件上传组件", + "miniprogram": "src", + "keywords": [ + "miniprogram", + "upload", + "image", + "weapp" + ], + "author": "Jerry", + "license": "ISC", + "publishConfig": { + "access": "public" + } +} diff --git a/node_modules/@beefast-wxmp/img-uploader/src/index.js b/node_modules/@beefast-wxmp/img-uploader/src/index.js new file mode 100644 index 0000000..fa6b5d4 --- /dev/null +++ b/node_modules/@beefast-wxmp/img-uploader/src/index.js @@ -0,0 +1,125 @@ +Component({ + + /** + * 组件的属性列表 + */ + properties: { + loading:{ + type:Boolean, + value:false + }, + maxImgCount:{ + type:Number, + value:10 + }, + /** + * url:上传地址 + * header:{} + */ + options:Object + }, + + /** + * 组件的初始数据 + */ + data: { + tempImgs:[] + }, + + /** + * 组件的方法列表 + */ + methods: { + chooseImage(){ + wx.chooseMedia({ + count:this.properties.maxImgCount - this.data.tempImgs.length, + mediaType:['image'], + sourceType:['camera'], + success:(res)=>{ + this.setData({ + tempImgs:this.data.tempImgs.concat(res.tempFiles) + }); + this.triggerEvent('imgChange',this.data.tempImgs); + this.uploadImages(); + } + }); + }, + async uploadImages(){ + let imgIndex = -1; + const file = this.data.tempImgs.find((item,index)=>{ + imgIndex = index; + return !item.uploaded; + }); + if(!file){ + this.setData({ + loading:false + }) + return; + } + this.setData({ + loading:true + }) + const task = wx.uploadFile({ + filePath: file.tempFilePath, + name: 'file', + header:this.properties.options.header||{}, + url: this.properties.options.url, + success:(res)=>{ + const response = JSON.parse(res.data); + this.setData({ + [`tempImgs[${imgIndex}].uploaded`]:true, + [`tempImgs[${imgIndex}].serverUrl`]:response.data.url + }) + this.uploadImages(); + }, + fail:(res)=>{ + this.setData({ + loading:false + }) + wx.showToast({ + icon:'error', + title: '上传失败', + }) + } + }); + file.task = task; + task.onProgressUpdate((res)=>{ + this.setData({ + [`tempImgs[${imgIndex}].progress`]:res.progress + }) + }) + }, + removeImage(event){ + const index = event.currentTarget.dataset.index; + if(this.data.tempImgs[index].task){ + this.data.tempImgs[index].task.abort(); + } + this.data.tempImgs.splice(index,1); + this.setData({ + tempImgs:this.data.tempImgs + }); + this.triggerEvent('imgChange',this.data.tempImgs); + }, + async getUploadedUrl(){ + await this.uploadImages(); + let urls = [],loadAll = true; + this.data.tempImgs.map((item)=>{ + if(!item.uploaded)loadAll = false; + urls.push(item.serverUrl); + }) + if(loadAll){ + return urls + } + throw new Error('图片上传失败'); + }, + setUploadedImgs(imgs){ + this.setData({ + tempImgs:imgs + }) + } + }, + lifetimes:{ + attached(){ + } + } +}) \ No newline at end of file diff --git a/node_modules/@beefast-wxmp/img-uploader/src/index.json b/node_modules/@beefast-wxmp/img-uploader/src/index.json new file mode 100644 index 0000000..6616525 --- /dev/null +++ b/node_modules/@beefast-wxmp/img-uploader/src/index.json @@ -0,0 +1,4 @@ +{ + "component": true, + "styleIsolation": "apply-shared" +} \ No newline at end of file diff --git a/node_modules/@beefast-wxmp/img-uploader/src/index.wxml b/node_modules/@beefast-wxmp/img-uploader/src/index.wxml new file mode 100644 index 0000000..1766e31 --- /dev/null +++ b/node_modules/@beefast-wxmp/img-uploader/src/index.wxml @@ -0,0 +1,13 @@ + + + + + + + + + + + 点击拍照 + + \ No newline at end of file diff --git a/node_modules/@beefast-wxmp/img-uploader/src/index.wxss b/node_modules/@beefast-wxmp/img-uploader/src/index.wxss new file mode 100644 index 0000000..3755b5b --- /dev/null +++ b/node_modules/@beefast-wxmp/img-uploader/src/index.wxss @@ -0,0 +1,68 @@ +.img-area{ + display: flex; + flex-wrap: wrap; + gap: 16rpx; + display: flex; + justify-content: flex-end; +} +.img-area .item{ + width: 100rpx;height:100rpx; + display: flex; + align-items: center; + justify-content: center; + flex-direction: column; + border-radius: 12rpx; + position: relative; + overflow: visible; +} + +.img-area .item .progress{ + position: absolute; + top:0;left:0; + width:100%; + z-index: 1; +} +.img-area .item .close-area{ + position: absolute; + right:-16rpx;top:-16rpx; + z-index: 2; + padding:5rpx; + display: flex; + align-items: center; + overflow: visible; +} +.img-area .item .close-area .icon{ + width:28rpx;height:28rpx; + border-radius: 50%; + background-color: rgba(153, 153, 153, 0.8); + -webkit-mask:url("data:image/svg+xml,%3C%3Fxml%20version%3D%221.0%22%20standalone%3D%22no%22%3F%3E%3C%21DOCTYPE%20svg%20PUBLIC%20%22-//W3C//DTD%20SVG%201.1//EN%22%20%22http%3A//www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd%22%3E%3Csvg%20t%3D%221741949551743%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%2225816%22%20xmlns%3Axlink%3D%22http%3A//www.w3.org/1999/xlink%22%20width%3D%22128%22%20height%3D%22128%22%3E%3Cpath%20d%3D%22M512%20992A480.512%20480.512%200%200%201%2032%20512%20480.512%20480.512%200%200%201%20512%2032a480.512%20480.512%200%200%201%20480%20480%20480.512%20480.512%200%200%201-480%20480z%20m0-434.624l135.68%20135.68a32%2032%200%200%200%2022.72%209.344%2032%2032%200%200%200%2022.528-9.344%2032%2032%200%200%200%209.344-22.592%2032%2032%200%200%200-9.344-22.656L557.184%20511.936l135.744-135.68a32%2032%200%200%200%209.472-22.784%2031.488%2031.488%200%200%200-9.472-22.464%2031.552%2031.552%200%200%200-22.656-9.472%2031.552%2031.552%200%200%200-22.656%209.472L511.936%20466.88%20376.064%20331.008a31.552%2031.552%200%200%200-22.656-9.472%2031.488%2031.488%200%200%200-22.592%209.472%2032%2032%200%200%200%200%2045.248l135.872%20135.68-135.872%20135.872a31.168%2031.168%200%200%200-9.344%2022.464%2031.616%2031.616%200%200%200%209.344%2022.72%2032%2032%200%200%200%2022.656%209.344A32%2032%200%200%200%20376%20692.992l135.872-135.68z%22%20p-id%3D%2225817%22%3E%3C/path%3E%3C/svg%3E") center/contain no-repeat; + background-position:center; + background-size:contain; + background-repeat: no-repeat; + /* center/contain no-repeat */ +} +.img-area .item.loading::after{ + content: ''; + position: absolute; + width:100%;height:100%; + left:0;top:0; + background-color: rgba(0, 0, 0, 0.3); + z-index: 0; +} +.img-area .item .image{ + width:100%;height:100%; + border-radius: 12rpx; +} + + +.img-area .take-photo{ + font-size: 20rpx; + color: rgba(153, 153, 153, 0.5); + border: 1.2px solid rgba(124, 134, 149, 0.3); +} +.img-area .take-photo .icon{ + width:32rpx;height:32rpx; + margin-bottom:14rpx; + background-color: currentColor; + -webkit-mask: url(data:image/svg+xml,%3C%3Fxml%20version%3D%221.0%22%20standalone%3D%22no%22%3F%3E%3C%21DOCTYPE%20svg%20PUBLIC%20%22-//W3C//DTD%20SVG%201.1//EN%22%20%22http%3A//www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd%22%3E%3Csvg%20t%3D%221741940716303%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%2214235%22%20xmlns%3Axlink%3D%22http%3A//www.w3.org/1999/xlink%22%20width%3D%22128%22%20height%3D%22128%22%3E%3Cpath%20d%3D%22M480%20352c-105.888%200-192%2086.112-192%20192s86.112%20192%20192%20192%20192-86.112%20192-192S585.888%20352%20480%20352zM480%20672c-70.592%200-128-57.408-128-128%200-70.592%2057.408-128%20128-128%2070.592%200%20128%2057.408%20128%20128C608%20614.592%20550.592%20672%20480%20672z%22%20fill%3D%22%235E6570%22%20p-id%3D%2214236%22%3E%3C/path%3E%3Cpath%20d%3D%22M576%20832%20160%20832c-17.632%200-32-14.336-32-32L128%20288c0-17.632%2014.368-32%2032-32l96%200c17.664%200%2032-14.336%2032-32S273.664%20192%20256%20192L160%20192C107.072%20192%2064%20235.072%2064%20288l0%20512c0%2052.928%2043.072%2096%2096%2096l416%200c17.696%200%2032-14.304%2032-32S593.696%20832%20576%20832z%22%20fill%3D%22%235E6570%22%20p-id%3D%2214237%22%3E%3C/path%3E%3Cpath%20d%3D%22M512%20256l320%200c17.664%200%2032%2014.368%2032%2032l0%20256c0%2017.696%2014.304%2032%2032%2032s32-14.304%2032-32L928%20288c0-52.928-43.072-96-96-96L512%20192c-17.664%200-32%2014.336-32%2032S494.336%20256%20512%20256z%22%20fill%3D%22%235E6570%22%20p-id%3D%2214238%22%3E%3C/path%3E%3Cpath%20d%3D%22M784%20336m-48%200a1.5%201.5%200%201%200%2096%200%201.5%201.5%200%201%200-96%200Z%22%20fill%3D%22%235E6570%22%20p-id%3D%2214239%22%3E%3C/path%3E%3Cpath%20d%3D%22M320%20160l128%200c17.696%200%2032-14.304%2032-32s-14.304-32-32-32l-128%200C302.304%2096%20288%20110.304%20288%20128S302.304%20160%20320%20160z%22%20fill%3D%22%235E6570%22%20p-id%3D%2214240%22%3E%3C/path%3E%3Cpath%20d%3D%22M960%20768l-96%200%200-96c0-17.696-14.304-32-32-32s-32%2014.304-32%2032l0%2096-96%200c-17.696%200-32%2014.304-32%2032s14.304%2032%2032%2032l96%200%200%2096c0%2017.696%2014.304%2032%2032%2032s32-14.304%2032-32l0-96%2096%200c17.696%200%2032-14.304%2032-32S977.696%20768%20960%20768z%22%20fill%3D%22%235E6570%22%20p-id%3D%2214241%22%3E%3C/path%3E%3C/svg%3E) center/contain no-repeat; +} \ No newline at end of file diff --git a/node_modules/@beefast-wxmp/list-view/package.json b/node_modules/@beefast-wxmp/list-view/package.json new file mode 100644 index 0000000..c66b04a --- /dev/null +++ b/node_modules/@beefast-wxmp/list-view/package.json @@ -0,0 +1,11 @@ +{ + "name": "@beefast-wxmp/list-view", + "version": "0.0.1", + "description": "", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "miniprogram": "src", + "author": "Jerry", + "license": "ISC" +} diff --git a/node_modules/@beefast-wxmp/list-view/src/index.js b/node_modules/@beefast-wxmp/list-view/src/index.js new file mode 100644 index 0000000..42e3cad --- /dev/null +++ b/node_modules/@beefast-wxmp/list-view/src/index.js @@ -0,0 +1,75 @@ +// components/listView/index.js +Component({ + + /** + * 组件的属性列表 + */ + properties: { + refresherTriggered:{ + type:Boolean, + value:false + }, + height:{ + type:Number, + value:0 + }, + loadMoreText:{ + type:String, + value:'已经到底了' + }, + showLoadMore:{ + type:Boolean, + value:true + }, + loadAll:{ + type:Boolean, + value:false + } + }, + + /** + * 组件的初始数据 + */ + data: { + heightStyle:'', + scrollHeight:0 + }, + lifetimes:{ + attached(){ + this.createSelectorQuery().select('#scrollView').boundingClientRect((res)=>{ + this.data.scrollHeight = res.height; + }).exec(); + const windowInfo = wx.getWindowInfo(); + } + }, + /** + * 组件的方法列表 + */ + methods: { + refreshList(){ + this.triggerEvent('refresh'); + }, + scrolling(event){ + //scrollTop scrollHeight + const bottomHeight = event.detail.scrollHeight-event.detail.scrollTop-this.data.scrollHeight; + if(bottomHeight<100){ + this.triggerEvent('loadMore'); + } + } + }, + observers:{ + height(h){ + let heightStyle = ''; + if(h){ + if(typeof h == 'string'){ + heightStyle = `height:${h}` + }else{ + heightStyle = `height:${this.properties.height*2}rpx` + } + this.setData({ + heightStyle:heightStyle + }) + } + } + } +}) \ No newline at end of file diff --git a/node_modules/@beefast-wxmp/list-view/src/index.json b/node_modules/@beefast-wxmp/list-view/src/index.json new file mode 100644 index 0000000..8b37bbf --- /dev/null +++ b/node_modules/@beefast-wxmp/list-view/src/index.json @@ -0,0 +1,5 @@ +{ + "component": true, + "usingComponents": {}, + "styleIsolation": "apply-shared" +} \ No newline at end of file diff --git a/node_modules/@beefast-wxmp/list-view/src/index.wxml b/node_modules/@beefast-wxmp/list-view/src/index.wxml new file mode 100644 index 0000000..3332b05 --- /dev/null +++ b/node_modules/@beefast-wxmp/list-view/src/index.wxml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/node_modules/@beefast-wxmp/list-view/src/index.wxss b/node_modules/@beefast-wxmp/list-view/src/index.wxss new file mode 100644 index 0000000..b83fa71 --- /dev/null +++ b/node_modules/@beefast-wxmp/list-view/src/index.wxss @@ -0,0 +1,24 @@ +.scroll-view{ + height:100%; +} +.load-more{ + padding:56rpx 0 80rpx 0; + text-align: center; + color: #888888; + font-size:24rpx; + position: relative; + width:80%; + margin:0 auto; +} +.load-more .text{ + background-color: var(--main-bgclolor); + padding:0 30rpx; +} +.load-more::before{ + content: ''; + position: absolute; + left:0;top:68rpx; + width:100%;height:1rpx; + background-color: rgba(136, 136, 136, 0.25); + z-index: -1; +} \ No newline at end of file diff --git a/node_modules/@beefast-wxmp/nav-bar/package.json b/node_modules/@beefast-wxmp/nav-bar/package.json new file mode 100644 index 0000000..94ce0c1 --- /dev/null +++ b/node_modules/@beefast-wxmp/nav-bar/package.json @@ -0,0 +1,12 @@ +{ + "name": "@beefast-wxmp/nav-bar", + "version": "0.0.3", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "miniprogram": "src", + "author": "Jerry", + "license": "ISC" +} diff --git a/node_modules/@beefast-wxmp/nav-bar/src/index.js b/node_modules/@beefast-wxmp/nav-bar/src/index.js new file mode 100644 index 0000000..2a7919a --- /dev/null +++ b/node_modules/@beefast-wxmp/nav-bar/src/index.js @@ -0,0 +1,68 @@ +// components/navBar.js +Component({ + options:{ + multipleSlots:true + }, + + /** + * 组件的属性列表 + */ + properties:{ + back:{ + type:Boolean, + value:false + }, + backTitle:{ + type:String, + value:'' + }, + background:{ + type:String, + value:'' + }, + homeUrl:String + }, + + /** + * 组件的初始数据 + */ + data: { + statusBarHeight:0, + navBarHeight:44, + canBack:true + }, + lifetimes:{ + attached(){ + const windowInfo = wx.getWindowInfo(); + this.setData({ + statusBarHeight:windowInfo.statusBarHeight + }); + const pages = getCurrentPages(); + if(pages.length>1){ + this.setData({ + canBack:true + }) + }else{ + this.setData({ + canBack:false + }) + } + } + }, + /** + * 组件的方法列表 + */ + methods: { + back(){ + wx.navigateBack(); + }, + backHome(){ + wx.reLaunch({ + url: this.properties.homeUrl, + }) + }, + getHeight(){ + return this.data.statusBarHeight + this.data.navBarHeight; + } + } +}) \ No newline at end of file diff --git a/node_modules/@beefast-wxmp/nav-bar/src/index.json b/node_modules/@beefast-wxmp/nav-bar/src/index.json new file mode 100644 index 0000000..8b37bbf --- /dev/null +++ b/node_modules/@beefast-wxmp/nav-bar/src/index.json @@ -0,0 +1,5 @@ +{ + "component": true, + "usingComponents": {}, + "styleIsolation": "apply-shared" +} \ No newline at end of file diff --git a/node_modules/@beefast-wxmp/nav-bar/src/index.wxml b/node_modules/@beefast-wxmp/nav-bar/src/index.wxml new file mode 100644 index 0000000..f6c910d --- /dev/null +++ b/node_modules/@beefast-wxmp/nav-bar/src/index.wxml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + {{backTitle}} + + + + + + + + \ No newline at end of file diff --git a/node_modules/@beefast-wxmp/nav-bar/src/index.wxss b/node_modules/@beefast-wxmp/nav-bar/src/index.wxss new file mode 100644 index 0000000..8eda36e --- /dev/null +++ b/node_modules/@beefast-wxmp/nav-bar/src/index.wxss @@ -0,0 +1,83 @@ +/* components/navBar.wxss */ +.nav-bar{ + transition-duration: .4s; + overflow: hidden; +} +.nav-bar .title{ + font-size: 36rpx; + font-weight: 600; + color:#222222; +} +.nav-bar-content{ + display: flex; + align-items: center; + justify-content: space-between; + padding:0 34rpx; +} +.nav-bar-content .left{ + flex:1; + display: flex; + align-items: center; + text-overflow: ellipsis; + max-width: calc(100vw - 140rpx); +} +.nav-bar-content .left .btns{ + display: inline-flex; + align-items: center; + border-radius: 60rpx; + vertical-align: middle; +} +.nav-bar-content .left .spliter{ + width:1.2rpx;height:36rpx; + background-color:#D8D8D8; +} +/*单一一个返回或者加上 backTitle的时候*/ +.nav-bar-content .back{ + font-size:40rpx; +} +.nav-bar-content .round{ + width:56rpx;height:56rpx; + border:1.2px solid rgba(255, 255, 255,.6); + box-sizing: border-box; + background-color: rgba(255, 255, 255, 0.3); + border-radius: 50%; + display: flex; + align-items: center; + justify-content: center; +} +.nav-bar-content .back-title{ + font-size: 36rpx; + font-weight: 600; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} +.nav-bar-content .center{ + flex:1; + text-align: center; +} +.nav-bar-content .right{flex:1;} + + +.nav-bar-content .back,.nav-bar-content .round .icon{ + width:1em;height:1em; + -webkit-mask-position:0 0; + mask-position:0 0; + -webkit-mask-repeat:no-repeat; + mask-repeat:no-repeat; + -webkit-mask-size:100%; + mask-size:100%; + background-color:currentColor; + -webkit-mask-image:var(--back-image); + mask-image: var(--back-image); +} +.nav-bar-content .round .icon{ + font-size: 40rpx; + mask-image: var(--back-home); + -webkit-mask-image: var(--back-home); +} + +page{ + --back-image:url(data:image/svg+xml,%3Csvg%20t%3D%221743422723228%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%2220325%22%20data-spm-anchor-id%3D%22a313x.search_index.0.i15.389b3a81Rr8Znb%22%20width%3D%22128%22%20height%3D%22128%22%3E%3Cpath%20d%3D%22M395.21518%20513.604544l323.135538-312.373427c19.052938-18.416442%2019.052938-48.273447%200-66.660212-19.053961-18.416442-49.910737-18.416442-68.964698%200L291.75176%20480.290811c-19.052938%2018.416442-19.052938%2048.273447%200%2066.660212l357.633237%20345.688183c9.525957%209.207709%2022.01234%2013.796214%2034.497699%2013.796214%2012.485359%200%2024.971741-4.588505%2034.466999-13.82896%2019.052938-18.416442%2019.052938-48.242747%200-66.660212L395.21518%20513.604544z%22%20fill%3D%22%23272636%22%20p-id%3D%2220326%22%3E%3C/path%3E%3C/svg%3E); + --back-home:url(data:image/svg+xml,%3Csvg%20t%3D%221743420332728%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%2216725%22%20width%3D%22128%22%20height%3D%22128%22%3E%3Cpath%20d%3D%22M946.5%20505L560.1%20118.8l-25.9-25.9c-12.3-12.2-32.1-12.2-44.4%200L77.5%20505c-12.3%2012.3-18.9%2028.6-18.8%2046%200.4%2035.2%2029.7%2063.3%2064.9%2063.3h42.5V940h691.8V614.3h43.4c17.1%200%2033.2-6.7%2045.3-18.8%2012.1-12.1%2018.7-28.2%2018.7-45.3%200-17-6.7-33.1-18.8-45.2zM568%20868H456V664h112v204z%20m217.9-325.7V868H632V640c0-22.1-17.9-40-40-40H432c-22.1%200-40%2017.9-40%2040v228H238.1V542.3h-96l370-369.7%2023.1%2023.1L882%20542.3h-96.1z%22%20p-id%3D%2216726%22%3E%3C/path%3E%3C/svg%3E) +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..edd566d --- /dev/null +++ b/package-lock.json @@ -0,0 +1,36 @@ +{ + "name": "meida", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "meida", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "@beefast-wxmp/img-uploader": "^0.1.6", + "@beefast-wxmp/list-view": "^0.0.1", + "@beefast-wxmp/nav-bar": "^0.0.3" + } + }, + "node_modules/@beefast-wxmp/img-uploader": { + "version": "0.1.6", + "resolved": "https://packages.aliyun.com/6486fc420ce788fc1c0798b3/npm/repo-glpby/@beefast-wxmp/img-uploader/-/@beefast-wxmp/img-uploader-0.1.6.tgz", + "integrity": "sha512-B4gltxYEDLZULpNDav8y7RtfFwSBgdLQgIb+9F6JWlLCPfZJHMe1AfIn1bQ1GftCPwNNr8l5EeTNip1kCfl1GQ==", + "license": "ISC" + }, + "node_modules/@beefast-wxmp/list-view": { + "version": "0.0.1", + "resolved": "https://packages.aliyun.com/6486fc420ce788fc1c0798b3/npm/repo-glpby/@beefast-wxmp/list-view/-/@beefast-wxmp/list-view-0.0.1.tgz", + "integrity": "sha512-XoTaXRqy8EuuHECGS2zFzAeDKoGDtC56VdahnVYTAcDLNo3fceQuXI2KhOSvjnn4Jbkt1UDch7IEuF9Eekf9eg==", + "license": "ISC" + }, + "node_modules/@beefast-wxmp/nav-bar": { + "version": "0.0.3", + "resolved": "https://packages.aliyun.com/6486fc420ce788fc1c0798b3/npm/repo-glpby/@beefast-wxmp/nav-bar/-/@beefast-wxmp/nav-bar-0.0.3.tgz", + "integrity": "sha512-h0CC32cTYguLhH+cap2LAUV7jeB6k6x6gWS3YUjkfYy6+v9XP3ohTAnuWsEDnWjJ+mJlARxdhwy8Phnl/Nuw2A==", + "license": "ISC" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..689256f --- /dev/null +++ b/package.json @@ -0,0 +1,18 @@ +{ + "name": "meida", + "version": "1.0.0", + "description": "微信小程序衣橱项目", + "main": "app.js", + "scripts": { + "dev": "miniprogram-ci preview", + "lint": "eslint .", + "format": "prettier --write ." + }, + "author": "", + "license": "ISC", + "dependencies": { + "@beefast-wxmp/img-uploader": "^0.1.6", + "@beefast-wxmp/list-view": "^0.0.1", + "@beefast-wxmp/nav-bar": "^0.0.3" + } +} diff --git a/pages/closet/index/index.js b/pages/closet/index/index.js new file mode 100644 index 0000000..fff6ca5 --- /dev/null +++ b/pages/closet/index/index.js @@ -0,0 +1,198 @@ +import clothingAPI from '../../../api/clothing'; +import commonAPI from '../../../api/common'; +import request from '../../../api/request'; +import userAPI from '../../../api/user'; + +Page({ + data: { + pager:{limit:10,loading:false,loadAll:false,pageIndex:0,refreshTriggered:false}, + uploadOptions:{ + url:`${request.baseURL}/api/v1/upload` + }, + uploadImg:{}, + uploading:false, + uploadPercent:0, + hasUploadImg:false, + isShowUploader:false, + + categories:[], + categoryIndex:0, + categoryUploadIndex:0, + + hasDefaultImage:false, + + topClothingCId:'', + bottomClothingCId:'' + }, + + onLoad() { + this.loadClosetList(); + clothingAPI.getCategories().then((data)=>{ + data.map((item)=>{ + if(item.name.indexOf('上衣')>-1||item.name.indexOf('衣服')>-1){ + this.data.topClothingCId = item.id; + } + if(item.name.indexOf('下衣')>-1||item.name.indexOf('裤子')>-1){ + this.data.bottomClothingCId = item.id; + } + }) + this.setData({ + categories:data + }) + }) + this.imgUploader = this.selectComponent('#imgUploader'); + }, + refreshList(){ + this.setData({ + 'pager.pageIndex':0, + 'pager.loadAll':false + }) + this.loadClosetList(); + }, + loadClosetList() { + if(this.data.pager.loading||this.data.pager.loadAll){ + return; + } + this.data.pager.loading = true; + this.setData({ + pager:this.data.pager + }); + const params = { + skip:this.data.pager.pageIndex*this.data.pager.limit, + limit:this.data.pager.limit + } + if(this.data.categoryIndex!=0){ + params.category_id = this.data.categories[this.data.categoryIndex-1].id + } + clothingAPI.getList(params).then((data)=>{ + if(this.data.pager.pageIndex==0){ + this.data.list = data; + }else{ + this.data.list = this.data.list.concat(data); + } + this.data.pager.loading = false; + this.data.pager.pageIndex++; + if(data.length{ + console.log('res',res); + this.setData({ + "pager.loading":false + }) + }); + }, + changeCategory(event){ + const categoryIndex = event.currentTarget.dataset.index; + this.data.pager.pageIndex = 0; + this.data.pager.loadAll = false; + this.setData({ + categoryIndex, + pager:this.data.pager + }) + this.loadClosetList(); + }, + changeUploadCategory(event){ + const categoryUploadIndex = event.currentTarget.dataset.index; + this.setData({ + categoryUploadIndex + }) + }, + addClothing(){ + this.setData({ + isShowUploader:true + }) + }, + chooseImg(){ + wx.chooseMedia({ + count:1, + success:(res)=>{ + let file = res.tempFiles[0]; + this.setData({ + uploadImg:file, + uploading:true + }) + commonAPI.upload(file).then((data)=>{ + this.setData({ + "uploadImg.serverUrl":data.url + }) + }).finally(()=>{ + this.setData({ + uploading:false + }) + }); + file.task.onProgressUpdate((detail)=>{ + console.log(detail); + this.setData({ + uploadPercent:detail.progress + }) + }) + } + }) + }, + saveClothing(){ + const cid = this.data.categories[this.data.categoryUploadIndex].id; + console.log(cid,this.data.uploadImg.serverUrl); + clothingAPI.create(cid,this.data.uploadImg.serverUrl).then(()=>{ + this.loadClosetList(); + this.setData({ + isShowUploader:false, + uploadImg:{} + }) + }); + }, + + + uploaderImgChange(event){ + this.setData({ + hasUploadImg:event.detail.length!=0 + }) + }, + + onShow(){ + userAPI.getDefaultPersonImage().then((data)=>{ + this.setData({ + hasDefaultImage:!!data.image_url + }) + }); + }, + toTry(event){ + const item = event.currentTarget.dataset.item; + const param = ''; + wx.switchTab({ + url: `/pages/try/index/index`, + success:()=>{ + const pages = getCurrentPages(); + const tryPage = pages[pages.length-1]; + console.log(this.data.topClothingCId,this.data.bottomClothingCId); + if(item.clothing_category_id==this.data.topClothingCId){ + tryPage.setTop(item.image_url); + }else if(item.clothing_category_id==this.data.bottomClothingCId){ + tryPage.setBottom(item.image_url); + } + } + }) + }, + + deleteClothing(event){ + const item = event.currentTarget.dataset.item; + wx.showModal({ + title: '是否确认删除这件衣服', + complete: (res) => { + if (res.confirm) { + clothingAPI.delete(item.id).then(()=>{ + wx.showToast({ + icon:'none', + title: '删除成功', + }); + this.refreshList(); + }) + } + } + }) + } +}); \ No newline at end of file diff --git a/pages/closet/index/index.json b/pages/closet/index/index.json new file mode 100644 index 0000000..4a0b8b2 --- /dev/null +++ b/pages/closet/index/index.json @@ -0,0 +1,8 @@ +{ + "usingComponents": { + "list-view":"/miniprogram_npm/@beefast-wxmp/list-view", + "img-uploader":"/miniprogram_npm/@beefast-wxmp/img-uploader", + "nav-bar":"/miniprogram_npm/@beefast-wxmp/nav-bar" + }, + "navigationStyle": "custom" +} \ No newline at end of file diff --git a/pages/closet/index/index.wxml b/pages/closet/index/index.wxml new file mode 100644 index 0000000..bb466c5 --- /dev/null +++ b/pages/closet/index/index.wxml @@ -0,0 +1,55 @@ + + + + 我的衣橱 + + + + + + + + + + + + 试穿 + + + + + + + + + + + + + + + + + + + + + + + 上传你的衣服 + + + + \ No newline at end of file diff --git a/pages/closet/index/index.wxss b/pages/closet/index/index.wxss new file mode 100644 index 0000000..e9140a5 --- /dev/null +++ b/pages/closet/index/index.wxss @@ -0,0 +1,138 @@ +.closet-container{ + padding:0 20rpx 0 20rpx; +} +.closet-container .header{ + display:flex; + align-items: center; + justify-content: space-between; + font-size: 40rpx; + font-weight: bold; +} +.closet-container .header .button{ + width:60rpx;height:60rpx; + padding:0; + line-height: 1; + display: flex; +} +.closet-container .category{ + margin:40rpx 0 20rpx 0; +} + +.list-content{ + display: flex; + flex-wrap: wrap; + gap: 40rpx; +} +.list .item{ + width:calc(50vw - 60rpx); + height:calc(50vw - 60rpx); + position: relative; +} +.list .item .image{ + width:100%;height:100%; + border-radius: 20rpx; +} +.list .item .delete-area{ + position: absolute; + top: 0; + right: 0; + padding:12rpx; +} +.list .item .to-try{ + position: absolute; + bottom: 0;right:0; + background-color: var(--main-color); + color: #fff; + padding:10rpx 18rpx; + border-radius: 20rpx 0 20rpx 0; +} + + +.add-clothing{ + padding:40rpx; +} +.closet-container .category{ + display: flex; + gap: 20rpx; +} +.add-clothing .category{ + display: flex; + gap: 20rpx; + justify-content: center; +} +.category .item{ + margin:0; + border-radius: 50rpx; + border-color: #000; + color: #000; +} +.category .item.current{ + background-color: #000; + color: #fff; +} +.add-clothing .button{ + margin-top:40rpx; +} +.add-clothing .upload-btn{ + border-radius: 20rpx; + height: 50vw; + width:100%; + background-color: var(--main-bgclolor); + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + color: #888; + font-size: 30rpx; + gap: 10rpx; + margin-top:40rpx; +} +.add-clothing .upload-btn .icon{ + font-size: 100rpx; +} +.upload-img-area{ + height: 50vw; + margin:40rpx 0; + position: relative; + overflow: hidden; + border-radius: 20rpx; +} +.upload-img-area .mask{ + position:absolute; + left:0;bottom:0; + width:100%;height:100%; + background-color: #999; + opacity: .5; +} +.upload-img-area .image{ + width:100%;height:100%; +} + + + + +.has-img .img-area{ + margin:40rpx 0; +} +.has-img .img-area .item{ + width:140rpx;height:140rpx; +} +.no-img .img-area .take-photo{ + border-radius: 20rpx; + height: 50vw; + width:100%; + background-color: var(--main-bgclolor); + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + color: #888; + font-size: 30rpx; + gap: 10rpx; + margin-top:40rpx; +} +.img-uploader .img-area .take-photo .icon{ + mask-image: var(--icon-cloud); + -webkit-mask-image:var(--icon-cloud); + width:100rpx;height:100rpx; +} \ No newline at end of file diff --git a/pages/my/index/index.js b/pages/my/index/index.js new file mode 100644 index 0000000..5014a65 --- /dev/null +++ b/pages/my/index/index.js @@ -0,0 +1,71 @@ +import userAPI from '../../../api/user'; + +Page({ + + /** + * 页面的初始数据 + */ + data: { + userInfo:{} + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + userAPI.getInfo().then((data)=>{ + this.setData({ + userInfo:data + }) + }) + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/pages/my/index/index.json b/pages/my/index/index.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/pages/my/index/index.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/my/index/index.wxml b/pages/my/index/index.wxml new file mode 100644 index 0000000..ca07f53 --- /dev/null +++ b/pages/my/index/index.wxml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + 我的收藏 + + + + + + + + 我的搭配 + + + + + + + + 历史记录 + + + + + + + + 设置 + + + + + \ No newline at end of file diff --git a/pages/my/index/index.wxss b/pages/my/index/index.wxss new file mode 100644 index 0000000..eb97611 --- /dev/null +++ b/pages/my/index/index.wxss @@ -0,0 +1,90 @@ +/* pages/my/index/index.wxss */ +.container { + padding: 0; + background-color: #fff; +} + +/* 用户信息卡片 */ +.user-card { + background: #fff; + padding: 40rpx 30rpx; + display: flex; + align-items: center; + margin-bottom: 20rpx; + border-bottom: 1rpx solid #f5f5f5; +} + +.avatar { + width: 140rpx; + height: 140rpx; + border-radius: 70rpx; + margin-right: 30rpx; + border: none; +} + +.user-info { + flex: 1; +} + +.nickname { + font-size: 40rpx; + font-weight: 600; + color: #FF2727; + margin-bottom: 12rpx; + display: block; +} + +.signature { + font-size: 28rpx; + color: #999; + display: block; +} + +/* 功能列表 */ +.function-list { + margin-top: 20rpx; +} + +.list-item { + display: flex; + align-items: center; + justify-content: space-between; + padding: 30rpx; + background: #fff; + border-bottom: 1rpx solid #f5f5f5; + transition: background-color 0.3s; +} + +.list-item:active { + background-color: #f9f9f9; +} + +.item-left { + display: flex; + align-items: center; +} + +.item-icon { + width: 48rpx; + height: 48rpx; + margin-right: 20rpx; + color: #FF2727; +} + +.item-text { + font-size: 32rpx; + color: #333; + font-weight: 400; +} + +.arrow { + width: 16rpx; + height: 16rpx; + border-top: 3rpx solid #FF2727; + border-right: 3rpx solid #FF2727; + transform: rotate(45deg); +} + +.list-item:active { + background-color: rgba(255, 39, 39, 0.05); +} \ No newline at end of file diff --git a/pages/my/login/index.js b/pages/my/login/index.js new file mode 100644 index 0000000..a9eff19 --- /dev/null +++ b/pages/my/login/index.js @@ -0,0 +1,91 @@ +import userAPI from '../../../api/user'; + + +Page({ + + /** + * 页面的初始数据 + */ + data: { + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + login(){ + wx.login({ + success: (res) => { + userAPI.login(res.code).then((data)=>{ + wx.setStorageSync('token', data.access_token); + wx.navigateBack({ + fail(){ + wx.reLaunch({ + url: '/pages/closet/index/index', + }) + } + }); + const pages = getCurrentPages(); + const prePage = pages[pages.length-2]; + if(prePage){ + prePage.onLoad(prePage.options); + } + }) + }, + }) + }, + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + const pages = getCurrentPages(); + const prePage = pages[pages.length-2]; + //这里应该是等路由动画完了之后调用onLoad 但是暂时没找到好的办法 + setTimeout(()=>{ + if(prePage){ + prePage.onLoad(prePage.options); + } + },300); + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/pages/my/login/index.json b/pages/my/login/index.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/pages/my/login/index.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/my/login/index.wxml b/pages/my/login/index.wxml new file mode 100644 index 0000000..28cfca2 --- /dev/null +++ b/pages/my/login/index.wxml @@ -0,0 +1,8 @@ + + + 搭配你的美,分享你的美 + + + + + \ No newline at end of file diff --git a/pages/my/login/index.wxss b/pages/my/login/index.wxss new file mode 100644 index 0000000..1231f21 --- /dev/null +++ b/pages/my/login/index.wxss @@ -0,0 +1,20 @@ +.top{ + text-align: center; + margin-top:200rpx; +} +.top .icon{ + width:300rpx; + height:100rpx; + margin:0 auto; +} +.top .tips{ + margin-top:40rpx; +} +.bottom{ + position: absolute; + bottom:calc(var(--safe-bottom) + 20rpx); + width:100%; +} +.bottom .button{ + margin:0 40rpx!important; +} \ No newline at end of file diff --git a/pages/try/index/index.js b/pages/try/index/index.js new file mode 100644 index 0000000..6be3959 --- /dev/null +++ b/pages/try/index/index.js @@ -0,0 +1,266 @@ +import userAPI from "../../../api/user"; +import commonAPI from "../../../api/common"; +import {rpxToPx} from '../../../utils/util'; + +// pages/try/index/index.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + personImage:{}, + topClothing:{}, + bottomClothing:{}, + uploadPercent:0, + defaultPersonImage:'', + imgHeight:0, + trying:false, + history:[], + currentHistory:{}, + + hasTryon:false, + personImageUploading:false + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(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 + }) + this.getDefaultPersonImage(); + this.getHistory(); + }, + getHistory(){ + userAPI.tryonHistory().then((data)=>{ + let hasTryon = false; + data.map((item)=>{ + if(!item.completion_url&&item.status!='失败'){ + hasTryon = true; + this.checkResult(item.id) + } + }) + this.setData({ + history:data, + hasTryon + }) + }) + }, + chooseImg(){ + wx.chooseMedia({ + count:1, + success:(res)=>{ + wx.cropImage({ + cropScale:'3:4', + src: res.tempFiles[0].tempFilePath, + success:(_res)=>{ + _res.uploading = true; + this.setData({ + personImage:_res + }) + commonAPI.upload(_res).then((data)=>{ + this.setData({ + "personImage.serverUrl":data.url + }); + userAPI.addPersonImages(data.url).then(()=>{ + return this.getDefaultPersonImage(); + }) + }).finally(()=>{ + this.setData({ + 'personImage.uploading':false + }) + }); + _res.task.onProgressUpdate((detail)=>{ + this.setData({ + uploadPercent:detail.progress + }) + }) + } + }) + } + }) + }, + + chooseTopClothing(){ + if(this.data.currentHistory&&this.data.currentHistory.id){ + return; + } + this.chooseAndUpload('topClothing'); + }, + chooseBottomClothing(){ + if(this.data.currentHistory&&this.data.currentHistory.id){ + return; + } + this.chooseAndUpload('bottomClothing'); + + }, + + chooseAndUpload(key){ + wx.chooseMedia({ + count:1, + success:(res)=>{ + let file = res.tempFiles[0]; + file.uploading = true; + this.setData({ + [key]:file + }) + commonAPI.upload(file).then((data)=>{ + this.setData({ + [`${key}.serverUrl`]:data.url + }) + }).finally(()=>{ + this.setData({ + [`${key}.uploading`]:false + }) + }); + } + }) + }, + + tryon(){ + if(!this.data.topClothing.serverUrl&&!this.data.bottomClothing.serverUrl){ + wx.showToast({ + title: '请先选择衣服', + }) + return; + } + this.setData({ + trying:true + }) + userAPI.tryon({ + top_clothing_url:this.data.topClothing.serverUrl, + bottom_clothing_url:this.data.bottomClothing.serverUrl + }).then((data)=>{ + this.getHistory(); + }).finally(()=>{ + this.setData({ + trying:false + }) + }) + }, + + checkResult(id){ + this.setData({ + hasTryon:true + }) + setTimeout(()=>{ + userAPI.checkTryon(id).then((data)=>{ + if(data.completion_url){ + this.getHistory(); + }else{ + this.checkResult(id); + } + }) + },1000); + }, + + selectHistory(event){ + const item = event.currentTarget.dataset.item; + this.setData({ + currentHistory:item + }) + }, + + addNew(){ + this.setData({ + currentHistory:{} + }) + }, + + deleteHistory(event){ + const item = event.currentTarget.dataset.item; + wx.showModal({ + title:'你确定删除这个搭配吗?', + complete: (res) => { + if (res.confirm) { + userAPI.deleteTryon(item.id).then(()=>{ + wx.showToast({ + icon:'none', + title: '删除成功', + }) + this.getHistory(); + }) + } + } + }) + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow(options) { + }, + getDefaultPersonImage(){ + userAPI.getDefaultPersonImage().then((data)=>{ + this.setData({ + defaultPersonImage:data.image_url + }) + }); + }, + setTop(url){ + this.setData({ + topClothing:{ + serverUrl:url, + tempFilePath:url + }, + currentHistory:{} + }) + }, + setBottom(url){ + this.setData({ + bottomClothing:{ + serverUrl:url, + tempFilePath:url + }, + currentHistory:{} + }) + }, + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/pages/try/index/index.json b/pages/try/index/index.json new file mode 100644 index 0000000..d3ac607 --- /dev/null +++ b/pages/try/index/index.json @@ -0,0 +1,6 @@ +{ + "usingComponents": { + "nav-bar":"/miniprogram_npm/@beefast-wxmp/nav-bar" + }, + "navigationStyle": "custom" +} \ No newline at end of file diff --git a/pages/try/index/index.wxml b/pages/try/index/index.wxml new file mode 100644 index 0000000..d051a3b --- /dev/null +++ b/pages/try/index/index.wxml @@ -0,0 +1,86 @@ + + + + + 我的试衣间 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 失败 + + + + + + + + + + + \ No newline at end of file diff --git a/pages/try/index/index.wxss b/pages/try/index/index.wxss new file mode 100644 index 0000000..b61afe4 --- /dev/null +++ b/pages/try/index/index.wxss @@ -0,0 +1,172 @@ +.try-container{ + height:100vh; + padding:0 40rpx 0 40rpx; + box-sizing: border-box; +} +.try-container .header{ + font-size: 40rpx; + font-weight: bold; + display: flex; + align-items: center; + justify-content:space-between; +} +.try-container .header .button{ + font-size: 28rpx; + font-weight: normal; + line-height: 2; +} +.try-container .main{ + border-radius: 20rpx; + margin-top:20rpx; + position: relative; + overflow: hidden; +} +.try-container .main .top-btn{ + position: absolute; + right:40rpx;top:40rpx; + z-index: 100; +} +.try-container .main .upload-btn{ + width:100%;height:100%; + position: absolute; + top:0;left:0; + display: flex; + flex-direction: column; + align-self: center; + justify-content: center; + text-align: center; + gap: 30rpx; +} +.try-container .main .person-image{ + width:100%;height:100%; +} +.try-container .main .upload-btn .icon{ + margin:0 auto; + width:calc(100vw - 80rpx); + height:calc(100vw - 80rpx); + color:#ccc; +} +.try-container .main .clothing{ + position: absolute; + left:20rpx;bottom:20rpx; + display: flex; + flex-direction: column; + align-items: center; + gap: 20rpx; +} +.try-container .main .clothing .loading-area{ + width:100%;height:100%; + background-color: rgba(0, 0, 0, .3); + position: absolute; + display: flex; + align-items: center; + justify-content: center; +} +.try-container .main .clothing .loading{ + font-size: 40rpx; + color:red +} +.try-container .main .item{ + position: relative; + background-color:rgba(255, 255, 255, .7); + width:100rpx;height:100rpx; + border-radius: 20rpx; + font-size: 80rpx; + display: flex; + align-items: center; + justify-content: center; + overflow: hidden; +} +.try-container .main .item .image{ + width:100%;height:100%; +} +.try-container .main .share-area{ + display: flex; + align-items: center; + justify-content: center; + font-size: 50rpx; + color: #fff; + margin-left:auto; + background-color: rgba(0, 0, 0, .1); + border-radius: 50%; + width: 80rpx;height: 80rpx; +} +.try-container .bottom{ + margin:40rpx 0 22rpx 0; +} + +.history{ + display: flex; + flex-wrap: nowrap; +} +.history .item{ + border-radius: 20rpx; + background-color: #ddd; + border:2px solid #ddd; + width:120rpx; + height: 120rpx; + display:flex; + align-items: center; + justify-content: center; + font-size: 60rpx; + color: #666; + position: relative; + flex-shrink: 0; + margin-left:16rpx; + margin-top:18rpx; +} +.history .item:first-child{ + margin-left:0; +} +.history .item.current{ + border-color: var(--main-color); +} +.history .image{ + width:100%;height:100%; +} +.history .loading-area{ + position: relative; + width:100%;height:100%; + background-color: rgba(0, 0, 0, .1); +} +.history .error-area{ + position: absolute; + left:0;top:0; + width:100%;height:100%; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + background-color: rgba(0, 0, 0, .2); + font-size: 40rpx; +} +.history .error-area .tips{ + font-size: 26rpx; + margin-top:8rpx; + color: red; +} +.history .delete-area{ + position:absolute; + top:-22rpx;right:-22rpx; + font-size: 36rpx; + color:red; + overflow: visible; + padding:8rpx; +} +.history .top-img{ + width:60%;height:60%; + position: absolute; + top:0;left:0; +} +.history .bottom-img{ + width:60%;height:60%; + position: absolute; + right:0;bottom:0; +} +.history .item .loading{ + position: absolute; + left:50%;top:50%; + font-size: 40rpx; + margin-left:-20rpx; + margin-top:-20rpx; +} \ No newline at end of file diff --git a/project.config.json b/project.config.json new file mode 100644 index 0000000..c79a971 --- /dev/null +++ b/project.config.json @@ -0,0 +1,28 @@ +{ + "compileType": "miniprogram", + "libVersion": "trial", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "auto", + "tabSize": 2 + }, + "appid": "wxfac912df4f9cdebe" +} \ No newline at end of file diff --git a/project.private.config.json b/project.private.config.json new file mode 100644 index 0000000..3ca0734 --- /dev/null +++ b/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "meida", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/sitemap.json b/sitemap.json new file mode 100644 index 0000000..ca02add --- /dev/null +++ b/sitemap.json @@ -0,0 +1,7 @@ +{ + "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", + "rules": [{ + "action": "allow", + "page": "*" + }] +} \ No newline at end of file diff --git a/utils/util.js b/utils/util.js new file mode 100644 index 0000000..eaea20f --- /dev/null +++ b/utils/util.js @@ -0,0 +1,25 @@ +const windowInfo = wx.getWindowInfo(); +const formatTime = date => { + const year = date.getFullYear() + const month = date.getMonth() + 1 + const day = date.getDate() + const hour = date.getHours() + const minute = date.getMinutes() + const second = date.getSeconds() + + return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}` +} + +const formatNumber = n => { + n = n.toString() + return n[1] ? n : `0${n}` +} + +const rpxToPx = (rpx) => { + return (rpx / 750) * windowInfo.windowWidth; +} + +module.exports = { + formatTime, + rpxToPx +}