diff --git a/miniprogram/app.json b/miniprogram/app.json index 8f109ad..cb7ea52 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -5,7 +5,8 @@ "pages/sign/index", "pages/user/login", "pages/logs/logs", - "pages/order/index" + "pages/order/index", + "pages/order/detail" ], "window": { "backgroundTextStyle": "light", @@ -14,8 +15,7 @@ "navigationBarTextStyle": "black" }, "tabBar": { - "list": [ - { + "list": [{ "pagePath": "pages/index/index", "iconPath": "assets/images/icon_home.png", "selectedIconPath": "assets/images/icon_home_selected.png", @@ -40,6 +40,8 @@ "v-button": "@vant/weapp/button/index", "v-tab": "@vant/weapp/tab/index", "v-tabs": "@vant/weapp/tabs/index", - "van-dialog": "@vant/weapp/dialog/index" + "van-dialog": "@vant/weapp/dialog/index", + "van-cell": "@vant/weapp/cell/index", + "van-cell-group": "@vant/weapp/cell-group/index" } } \ No newline at end of file diff --git a/miniprogram/app.less b/miniprogram/app.less index b4a8591..591d72c 100644 --- a/miniprogram/app.less +++ b/miniprogram/app.less @@ -1,8 +1,8 @@ @font-face { font-family: "iconfont"; /* Project id 3795683 */ - src: url('./assets/font/iconfont.woff') format('woff2'), - url('./assets/font/iconfont.woff?t=1669601953874') format('woff'), - url('./assets/font/iconfont.ttf?t=1669601953874') format('truetype'); + src: url('https://at.alicdn.com/t/c/font_3795683_hbxadrued4a.woff2?t=1676964840714') format('woff2'), + url('https://at.alicdn.com/t/c/font_3795683_hbxadrued4a.woff?t=1676964840714') format('woff'), + url('https://at.alicdn.com/t/c/font_3795683_hbxadrued4a.ttf?t=1676964840714') format('truetype'); } .iconfont { diff --git a/miniprogram/config.ts b/miniprogram/config.ts index 53e4d83..b81402e 100644 --- a/miniprogram/config.ts +++ b/miniprogram/config.ts @@ -4,11 +4,11 @@ type ApplicationConfig = { } const ConfigData = { dev: { - api_url: 'http://localhost:8080', + api_url: 'http://192.168.10.64:8080', env: 'dev' }, prod: { - api_url: 'http://localhost:8001', + api_url: 'http://192.168.10.64:8001', env: 'prod' } } diff --git a/miniprogram/pages/index/index.less b/miniprogram/pages/index/index.less index c5ce7d3..3d9c8c2 100644 --- a/miniprogram/pages/index/index.less +++ b/miniprogram/pages/index/index.less @@ -154,6 +154,13 @@ image { width: 100px; padding: 0; line-height: 30px; + &.disabled{ + background-color: #ddd; + color:#999; + &:active{ + background-color: #ddd; + } + } &:active{ background-color: rgb(233, 0, 0); } diff --git a/miniprogram/pages/index/index.ts b/miniprogram/pages/index/index.ts index f6ec528..730ad85 100644 --- a/miniprogram/pages/index/index.ts +++ b/miniprogram/pages/index/index.ts @@ -11,25 +11,30 @@ Page({ { image: 'https://m15.360buyimg.com/mobilecms/jfs/t1/160398/4/32302/103427/6374d1f3E5b1ecb32/a593b9982d8378cc.jpg!cr_1125x449_0_166!q70.jpg', url: null, + id:1, }, { image: 'https://m15.360buyimg.com/mobilecms/jfs/t1/203775/20/26428/95041/637fab4dEf6a4434d/3f8770efe691537b.jpg!cr_1053x420_4_0!q70.jpg', url: null, + id:2, }, { image: 'https://m15.360buyimg.com/mobilecms/jfs/t1/160398/4/32302/103427/6374d1f3E5b1ecb32/a593b9982d8378cc.jpg!cr_1125x449_0_166!q70.jpg', url: null, + id:3, }, { image: 'https://m15.360buyimg.com/mobilecms/jfs/t1/203775/20/26428/95041/637fab4dEf6a4434d/3f8770efe691537b.jpg!cr_1053x420_4_0!q70.jpg', url: null, + id:4, } ], goodsItems: [], recommendItems: [], page: 1, hasMore: true, - pageSize: 10 + pageSize: 10, + userPoint: -1, }, onPullDownRefresh() { this.setData({ @@ -65,6 +70,11 @@ Page({ }) }, onLoad() { + if(app.globalData.userInfo && app.globalData.userInfo.pointInfo){ + this.setData({ + userPoint: app.globalData.userInfo.pointInfo.totalPoint + }) + } // 推荐商品 queryGoodsList(2, 1, 3).then((result) => { wx.stopPullDownRefresh(); @@ -77,7 +87,7 @@ Page({ this.loadGoodsList(this.data.page); }, createOrder(e: any) { - if(!app.globalData.token){ + if(!app.globalData.token || !app.globalData.userInfo){ // message.toast('请先完成登录','none',()=>{ // }) @@ -87,16 +97,24 @@ Page({ return false; } const goods = e.target.dataset.data as Goods; - message.showLoading({ message: '兑换中...' }) - createOrder(goods.id).then(result => { - console.log(result) - // 更新用户信息 - app.updateUserInfo(); - message.toast('兑换成功') - }).catch(e => { - message.toast(e.message || '兑换失败') - }).finally(() => { - message.hideLoading() + if(goods.price > app.globalData.userInfo.pointInfo.totalPoint){ + message.alert('积分不足') + return; + } + message.confirm('确认兑换此商品吗?').then(b=>{ + if(b){ + message.showLoading({ message: '兑换中...' }) + createOrder(goods.id).then(result => { + console.log(result) + // 更新用户信息 + app.updateUserInfo(); + message.toast('兑换成功') + }).catch(e => { + message.toast(e.message || '兑换失败') + }).finally(() => { + message.hideLoading() + }) + } }) return; } diff --git a/miniprogram/pages/index/index.wxml b/miniprogram/pages/index/index.wxml index e4aa6a5..bab8ba3 100644 --- a/miniprogram/pages/index/index.wxml +++ b/miniprogram/pages/index/index.wxml @@ -4,7 +4,7 @@ - + @@ -68,7 +68,8 @@ {{item.price}}积分 - + + diff --git a/miniprogram/pages/order/detail.json b/miniprogram/pages/order/detail.json new file mode 100644 index 0000000..542a5e0 --- /dev/null +++ b/miniprogram/pages/order/detail.json @@ -0,0 +1,6 @@ +{ + "usingComponents": {}, + "navigationBarBackgroundColor": "#f2f2f2", + "navigationBarTitleText": "订单详情", + "enablePullDownRefresh": true +} \ No newline at end of file diff --git a/miniprogram/pages/order/detail.less b/miniprogram/pages/order/detail.less new file mode 100644 index 0000000..05d7330 --- /dev/null +++ b/miniprogram/pages/order/detail.less @@ -0,0 +1,87 @@ +/* pages/order/detail.wxss */ + +@padding: 15px; +@content_padding: 15px; +.order-detail-page { + background-color: #f2f2f2; + min-height: 100vh; + --padding-xs: 15px; + .order-status { + padding: 20px 30px; + background-color: #ffffff; + font-size: 18px; + } + + .order-goods,.order-info-detail { + background-color: #ffffff; + margin: 15px; + border-radius: 10px; + overflow: hidden; + } + .order-info-detail{ + font-size: 13px; + padding: 10px 0; + .item { + display: flex; + align-items: center; + padding: 5px 15px; + } + .title{ + margin-right: 5px; + } + } + + .order-goods-content { + + padding: @content_padding; + + .info { + display: flex; + } + + .goods-name { + flex: 1; + margin: 0 8px; + font-size: 15px; + line-height: 1.3; + } + + .goods-price { + color: #999; + text-align: right; + } + + .sale-price { + color: #333; + } + + .origin-price { + text-decoration: line-through; + } + } + + .goods-cover-image { + width: 100px; + height: 100px; + } + + .price { + text-align: right; + font-size: 13px; + + .price-total { + font-size: 16px; + vertical-align: baseline; + } + } + + .order-footer { + border-top: 1px solid #f2f2f2; + overflow: hidden; + padding: 15px; + } + .order-action{ + float: right; + } + +} \ No newline at end of file diff --git a/miniprogram/pages/order/detail.ts b/miniprogram/pages/order/detail.ts new file mode 100644 index 0000000..4f64829 --- /dev/null +++ b/miniprogram/pages/order/detail.ts @@ -0,0 +1,69 @@ +import { queryOrderDetail } from "../../service/shop-api"; +import message from "../../utils/message"; + +// pages/order/detail.ts +Page({ + + /** + * 页面的初始数据 + */ + data: { + statusEnums: { + 1: '待确认', + 2: '已确认', + 3: '已取消', + 4: '已完成', + 0: '已删除' + }, + id: '', + order: {} + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(opts: { id?: string }) { + if (!opts.id) { + message.alert('订单数据错误').then(() => wx.navigateBack()); + return; + } + this.setData({ + id: opts.id + }) + this.loadOrderDetail(opts.id) + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + onPullDownRefresh(){ + this.loadOrderDetail() + }, + async loadOrderDetail(id?: string) { + message.showLoading() + try{ + const order = await queryOrderDetail((id || this.data.id)); + this.setData({ order }) + wx.stopPullDownRefresh() + }finally{ + message.hideLoading() + } + } +}) \ No newline at end of file diff --git a/miniprogram/pages/order/detail.wxml b/miniprogram/pages/order/detail.wxml new file mode 100644 index 0000000..6213b5c --- /dev/null +++ b/miniprogram/pages/order/detail.wxml @@ -0,0 +1,48 @@ + + + + {{statusEnums[order.status]||''}} + + + + + + + + + + {{order.goods.title}} + + + {{order.goods.price}} + {{order.goods.originPrice}} + × 1 + + + + 实付积分: + {{order.price}} + + + + + 取消订单 + 删除订单 + + + + + + 订单编号: + {{order.id}} + + + 创建时间: + {{order.createTime}} + + + 更新时间: + {{order.updateTime}} + + + \ No newline at end of file diff --git a/miniprogram/pages/order/index.less b/miniprogram/pages/order/index.less index 52b24e5..c26dac9 100644 --- a/miniprogram/pages/order/index.less +++ b/miniprogram/pages/order/index.less @@ -24,7 +24,11 @@ .order-footer { border-top: 1px solid #f2f2f2; } - + .order-no{ + border-bottom: 1px solid #f2f2f2; + padding: 10px; + font-size: 13px; + } .order-goods-content { padding: @content_padding; @@ -34,8 +38,8 @@ .goods-name{ flex:1; margin: 0 8px; - font-size: 16px; - line-height: 1.5; + font-size: 15px; + line-height: 1.3; } .goods-price{ color:#999; @@ -72,7 +76,7 @@ .order-status { display: flex; align-items: center; - font-size: 18px; + font-size: 14px; color: #c78a8a; } diff --git a/miniprogram/pages/order/index.ts b/miniprogram/pages/order/index.ts index fef1e29..d1ebb5b 100644 --- a/miniprogram/pages/order/index.ts +++ b/miniprogram/pages/order/index.ts @@ -86,6 +86,13 @@ Page({ this.loadOrderList(tabActive) this.setData({ tabActive }) }, + showOrderDetail(e: TapEvent){ + const id = e.currentTarget.id + + wx.navigateTo({ + url: `/pages/order/detail?id=${id}` + }) + }, async cancelOrder(e: TapEvent) { try { if ((await message.confirm('确定要取消订单?'))) { diff --git a/miniprogram/pages/order/index.wxml b/miniprogram/pages/order/index.wxml index d6df711..a50a7a3 100644 --- a/miniprogram/pages/order/index.wxml +++ b/miniprogram/pages/order/index.wxml @@ -4,8 +4,13 @@ + + + 订单编号: + {{o.id}} + - + diff --git a/miniprogram/pages/personal/personal.less b/miniprogram/pages/personal/personal.less index 1f8d743..52ef0ca 100644 --- a/miniprogram/pages/personal/personal.less +++ b/miniprogram/pages/personal/personal.less @@ -25,9 +25,8 @@ } .icon-sign{ background: linear-gradient(to right,#ddba7a,#ff9a31); - } - .icon-game{ + .item-icon-game{ background: linear-gradient(to right,#ffaf8f,#ff6931); } diff --git a/miniprogram/pages/personal/personal.wxml b/miniprogram/pages/personal/personal.wxml index b037270..1c98cc1 100644 --- a/miniprogram/pages/personal/personal.wxml +++ b/miniprogram/pages/personal/personal.wxml @@ -22,7 +22,7 @@ - 每次签到 + 签到 @@ -34,7 +34,7 @@ - + @@ -42,7 +42,7 @@ - + diff --git a/miniprogram/pages/sign/index.ts b/miniprogram/pages/sign/index.ts index 410b577..bf98541 100644 --- a/miniprogram/pages/sign/index.ts +++ b/miniprogram/pages/sign/index.ts @@ -29,9 +29,11 @@ Page({ */ onLoad() { if (app.globalData.userInfo) { - this.setData({ - pointValue: app.globalData.userInfo?.pointInfo?.totalPoint - }) + if(app.globalData.userInfo.pointInfo){ + this.setData({ + pointValue: app.globalData.userInfo.pointInfo.totalPoint + }) + } signInfo().then(res => { this.setData(res) }) diff --git a/miniprogram/service/shop-api.ts b/miniprogram/service/shop-api.ts index 3bfeae3..b8a3d3c 100644 --- a/miniprogram/service/shop-api.ts +++ b/miniprogram/service/shop-api.ts @@ -48,6 +48,9 @@ export function queryOrderList(status: number = 0, page = 1, pageSize = 10) { status, page, pageSize }); } +export function queryOrderDetail(id: string){ + return request(`/shop/order/${id}`,null,'GET'); +} export function cancelOrder(id: string) { return request(`/shop/order/${id}/cancel`,null,'PUT'); } diff --git a/miniprogram/utils/message.ts b/miniprogram/utils/message.ts index c58b889..56f45d6 100644 --- a/miniprogram/utils/message.ts +++ b/miniprogram/utils/message.ts @@ -15,7 +15,7 @@ export function toast(message: string | any, icon: ToastIcon = 'none', callback: icon }) } -export function showLoading({ message = '加载中...', mask = true }) { +export function showLoading({ message = '加载中...', mask = true }={}) { return wx.showLoading({ title: message, mask @@ -24,6 +24,14 @@ export function showLoading({ message = '加载中...', mask = true }) { export function hideLoading() { wx.hideLoading() } +export function alert(message: string) { + return new Promise((success) => { + wx.showModal({ + content: message, + success + }) + }) +} export function confirm(message: string) { return new Promise((resolve) => { wx.showModal({ @@ -43,5 +51,6 @@ export default { toast, showLoading, hideLoading, + alert, confirm, } \ No newline at end of file diff --git a/project.private.config.json b/project.private.config.json index f7e3777..51bd474 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -1,8 +1,9 @@ { "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", - "projectname": "userlogin-demo", + "projectname": "point_sys_miniapp", "setting": { "compileHotReLoad": true, - "urlCheck": false + "urlCheck": false, + "bigPackageSizeSupport": true } } \ No newline at end of file diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..7765358 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,18 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@types/node@^18.11.9": + version "18.14.0" + resolved "https://registry.npmmirror.com/@types/node/-/node-18.14.0.tgz#94c47b9217bbac49d4a67a967fdcdeed89ebb7d0" + integrity sha512-5EWrvLmglK+imbCJY0+INViFWUHg1AHel1sq4ZVSfdcNqGy9Edv3UB9IIzzg+xPaUcAgZYcfVs2fBcwDeZzU0A== + +"@vant/weapp@^1.10.8": + version "1.10.13" + resolved "https://registry.npmmirror.com/@vant/weapp/-/weapp-1.10.13.tgz#795c52b4e5a757ad02091df2c9910e63daabffe6" + integrity sha512-Ps56qHY60W0QpaFKgzN2UGWfzCcKfZrM7QZVfFM3Qx9Kpm/Tnqln+mrGSMiI84+6qU0Bv1xKX6FBDa04yNiwAQ== + +miniprogram-api-typings@^3.6.0: + version "3.9.0" + resolved "https://registry.npmmirror.com/miniprogram-api-typings/-/miniprogram-api-typings-3.9.0.tgz#c04a6b7eae5585733b5f8787297f2b9f1b60abac" + integrity sha512-QCXHHW9H4XYazb8J9EMiFyaOWHXhBG4oehkQqi+76FJpKKIlpgL0ZkXxzJ2L+6T/c5OxKm7iegovKIQGVkZDLQ==