diff --git a/api/http.js b/api/http.js index 3f66ca9..9cd5832 100644 --- a/api/http.js +++ b/api/http.js @@ -3,7 +3,8 @@ const baseURL = 'http://192.168.0.112:8088/api/'; export function $http(methods,url,params){ var header = { 'content-type': 'application/json', - 'Authorization' : wx.getStorageSync('token') || '' + 'Authorization' :'Bearer '+ wx.getStorageSync('token') || '', + 'dept': '22' }; return new Promise((resolve,reject)=>{ wx.showLoading({ @@ -21,8 +22,17 @@ export function $http(methods,url,params){ wx.navigateTo({ url: '/pages/login/index', }) + return + } + if(res.data.success){ + resolve(res); + } else{ + wx.showToast({ + title: '服务器错误,请稍后再试!', + icon : 'none' + }) + reject(err) } - resolve(res); }, fail: err=> { wx.hideLoading(); diff --git a/api/store.js b/api/store.js new file mode 100644 index 0000000..ef53390 --- /dev/null +++ b/api/store.js @@ -0,0 +1,22 @@ +const http = require('./http.js') + +/* + * 商品分类 + * */ +export function getCategory() { + return http.$http('get','category'); +} + +/* + * 商品列表 + * */ +export function getProducts(q) { + return http.$http('get','products',q) +} +/* + * 商品详情 + * */ +export function getProductDetail(id) { + return http.$http('get',"/product/detail/" + id) +} + diff --git a/api/user.js b/api/user.js index 22617cf..1e7cbac 100644 --- a/api/user.js +++ b/api/user.js @@ -1,12 +1,25 @@ const http = require('./http.js') +//绑定手机号 export function bingPhone(){ - return new Promise((resolve,reject)=> { - http.$http().then((res)=>{ - if(res.success){ - resolve(res) - } else{ - resolve(res) - } - }) - }) -} \ No newline at end of file + return http.$http() +} +//获取用户信息 +export function getUserInfo(){ + return http.$http('get','userinfo') +} + +//立即咨询 +export function saleLeads(data){ + return http.$http('post','user/saleLeads',data) +} + +// 获取我的团队 +export function getMyTeam(){ + return http.$http('get','getTeam') +} + +// 积分动态 +export function getIntegralList(data){ + return http.$http('get','integral/list',data) +} + diff --git a/app.js b/app.js index d357258..5f74709 100644 --- a/app.js +++ b/app.js @@ -2,7 +2,6 @@ const http = require('./api/http.js') App({ onLaunch() { - // 登录 }, login(){ return new Promise((resolve,reject)=>{ @@ -17,10 +16,23 @@ App({ let data = { code: result.code, iv: res.iv, - encryptedData:res.encryptedData + encryptedData: res.encryptedData } + console.log(data) http.$http('post','wxapp/auth',data).then((result)=>{ - console.log('数据已返回') + if(result.data.success){ + wx.setStorageSync('token', result.data.data.token) + wx.setStorageSync('userInfo', result.data.data.user) + wx.showToast({ + title: '授权成功!', + icon: 'none' + }) + } else{ + wx.showToast({ + title: result.data.msg, + icon: 'none' + }) + } resolve(result) }) } @@ -33,6 +45,7 @@ App({ }) }, globalData: { - $http: http.$http + http: http.$http, + products: [] } -}) +}) \ No newline at end of file diff --git a/app.json b/app.json index 9947d36..fc1baa2 100644 --- a/app.json +++ b/app.json @@ -1,5 +1,6 @@ { "pages":[ + "pages/home/index", "pages/goodsList/index", "pages/goodsDetail/index", diff --git a/app.wxss b/app.wxss index c505c9b..c9b07ba 100644 --- a/app.wxss +++ b/app.wxss @@ -11,7 +11,6 @@ image { box-sizing: border-box; } image{ - /* border-radius: 8rpx; */ width: 100%; height: 100%; } @@ -96,3 +95,9 @@ image{ margin: 60rpx auto; } + +.loading-status{ + text-align: center; + font-size: 28rpx; + color: #B9B9B9; +} \ No newline at end of file diff --git a/pages/companyInfo/index.js b/pages/companyInfo/index.js index e4ab356..f49dabd 100644 --- a/pages/companyInfo/index.js +++ b/pages/companyInfo/index.js @@ -1,21 +1,24 @@ // pages/companyInfo/index.js +const app = getApp() Page({ /** * 页面的初始数据 */ data: { - + products: app.globalData.products }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + this.setData({ + products: app.globalData.products + }) }, toList(){ - wx.navigateTo({ + wx.switchTab({ url: '/pages/goodsList/index', }) }, diff --git a/pages/companyInfo/index.wxml b/pages/companyInfo/index.wxml index 3917c3a..627fb17 100644 --- a/pages/companyInfo/index.wxml +++ b/pages/companyInfo/index.wxml @@ -13,9 +13,9 @@ - - - + + + 更多商品 diff --git a/pages/companyInfo/index.wxss b/pages/companyInfo/index.wxss index 75f525e..5f75be8 100644 --- a/pages/companyInfo/index.wxss +++ b/pages/companyInfo/index.wxss @@ -25,8 +25,8 @@ .introduse-box{ padding: 12rpx 0; color: #0B204C; - font-size: 24rpx; - line-height: 34rpx; + font-size: 28rpx; + line-height: 42rpx; font-weight: 500; text-indent: 1em; } diff --git a/pages/goodsDetail/index.js b/pages/goodsDetail/index.js index 650f442..80985a9 100644 --- a/pages/goodsDetail/index.js +++ b/pages/goodsDetail/index.js @@ -1,42 +1,101 @@ // pages/goodsDetail/index.js +const app = getApp() +const user = require('../../api/user.js') +const store = require('../../api/store.js') Page({ /** * 页面的初始数据 */ data: { - + showMask: false, + form:{ + name: '', + phone: '', + id: '' + }, + detail: {} }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + this.setData({ + 'form.id': options.id + }) + }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + this.getProductDetail() + }, + getProductDetail(){ + store.getProductDetail(this.data.form.id).then((res)=>{ + console.log('detail',res) + res.data.data.storeInfo.description.replace(/\{ + wx.showModal({ + title: '温馨提示', + content: '恭喜您预约成功,稍后会有专属服务老师与您联系。', + showCancel: false + }) + this.setData({ + showMask: false + }) + }) + }, + alertMessage(msg){ + wx.showToast({ + title: msg, + icon: 'none' + }) }, toHome(){ - wx.navigateTo({ + wx.switchTab({ url: '/pages/home/index', }) }, toList(){ - wx.navigateTo({ + wx.switchTab({ url: '/pages/goodsList/index', }) }, - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, + /** * 生命周期函数--监听页面隐藏 @@ -70,6 +129,10 @@ Page({ * 用户点击右上角分享 */ onShareAppMessage: function () { - + return{ + title: this.data.detail.storeInfo.storeName, + imageUrl: this.data.detail.storeInfo.image, + path: '/pages/goodsDetail/index?id='+ this.data.detail.storeInfo.id + } } }) \ No newline at end of file diff --git a/pages/goodsDetail/index.wxml b/pages/goodsDetail/index.wxml index 9d6fbe1..6fa9434 100644 --- a/pages/goodsDetail/index.wxml +++ b/pages/goodsDetail/index.wxml @@ -2,23 +2,21 @@ - + - - - + - 瑞梦思·布胡斯智能床垫 - 129000-289000 - 原价:¥99999 + {{detail.storeInfo.storeName}} + {{detail.storeInfo.price}} + 原价:¥{{detail.storeInfo.otPrice}} - 销量:999+ + 销量:{{detail.storeInfo.sales}} - - 立即咨询 + + + 立即预约 diff --git a/pages/home/index.wxss b/pages/home/index.wxss index f14c7e2..00b67bf 100644 --- a/pages/home/index.wxss +++ b/pages/home/index.wxss @@ -121,4 +121,5 @@ .submit-btn{ width: 318rpx !important; padding: 0 !important; -} \ No newline at end of file +} + diff --git a/pages/login/index.js b/pages/login/index.js index 0b0aeff..ef6ea22 100644 --- a/pages/login/index.js +++ b/pages/login/index.js @@ -22,14 +22,13 @@ Page({ }, getUserProfile(e) { // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗 - wx.getUserProfile({ - desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写 - success: (response) => { - wx.showLoading({ - title: '登陆中...', + app.login().then((res)=>{ + if(res.data.success){ + wx.navigateBack({ + delta: 1, }) } - }) + }) }, getPhoneNumber(e) { if(e.detail.errMsg == 'getPhoneNumber:ok'){ diff --git a/pages/user/cashOut/index.js b/pages/user/cashOut/index.js index 36122bd..247fa3f 100644 --- a/pages/user/cashOut/index.js +++ b/pages/user/cashOut/index.js @@ -5,14 +5,17 @@ Page({ * 页面的初始数据 */ data: { - + brokeragePrice: 20 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + console.log(options) + this.setData({ + brokeragePrice: options.brokeragePrice + }) }, /** diff --git a/pages/user/cashOut/index.wxml b/pages/user/cashOut/index.wxml index 6971c3f..28a1e89 100644 --- a/pages/user/cashOut/index.wxml +++ b/pages/user/cashOut/index.wxml @@ -4,7 +4,7 @@ 当前可提现积分(积分比例为1:1) - 300 + {{brokeragePrice}} 注:提现需在每月20-26日进行,其他时间不可提现 @@ -16,4 +16,5 @@ 全部提现 + 提现 diff --git a/pages/user/cashOut/index.wxss b/pages/user/cashOut/index.wxss index c50af4b..81cc0f3 100644 --- a/pages/user/cashOut/index.wxss +++ b/pages/user/cashOut/index.wxss @@ -65,4 +65,15 @@ } .colO{ color: #F68514; +} +.submit-btn{ + width: 440rpx; + height: 88rpx; + background: #F7C37A; + border-radius: 44rpx; + text-align: center; + line-height: 88rpx; + font-size: 42rpx; + color: #FFFFFF; + margin: 110rpx auto 0; } \ No newline at end of file diff --git a/pages/user/index.js b/pages/user/index.js index b77c4e8..b536a71 100644 --- a/pages/user/index.js +++ b/pages/user/index.js @@ -7,32 +7,37 @@ Page({ * 页面的初始数据 */ data: { - + userInfo: {} }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { - userApi.bingPhone().then(res=>{ - console.log(res) - }) - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - + // userApi.getMyTeam().then((res)=>{ + // console.log(res) + // }) + }, - + /** * 生命周期函数--监听页面显示 */ onShow: function () { - + this.getUserInfo() + }, + getUserInfo(){ + userApi.getUserInfo().then((res)=> { + this.setData({ + userInfo: res.data.data + }) + }) + }, + toCashOut(){ + wx.navigateTo({ + url: '/pages/user/cashOut/index?brokeragePrice=' + this.data.userInfo.brokeragePrice, + }) }, - /** * 生命周期函数--监听页面隐藏 */ diff --git a/pages/user/index.json b/pages/user/index.json index 7f39eb5..b2597ff 100644 --- a/pages/user/index.json +++ b/pages/user/index.json @@ -1,4 +1,5 @@ { "usingComponents": {}, - "navigationBarTitleText": "我的" + "navigationBarTitleText": "我的", + "enablePullDownRefresh": true } \ No newline at end of file diff --git a/pages/user/index.wxml b/pages/user/index.wxml index 31636cd..24fe7d1 100644 --- a/pages/user/index.wxml +++ b/pages/user/index.wxml @@ -1,10 +1,10 @@ - + - 赵铁柱 - ID:2123 + {{userInfo.nickname || '瑞梦思'}} + ID:{{userInfo.uid}} @@ -13,53 +13,57 @@ 今日收益 - 200积分 + {{userInfo.todayBrokerage || 0}}积分 累计收益 - 200积分 + {{userInfo.brokeragePrice || 0}}积分 推广人数 - 20人 + {{userInfo.spreadCount || 0}}人 - 今日收益 - 20人 + 今日新增 + {{userInfo.todaySpreadNum || 0}}人 - - - 积分详情 - - + + + + 积分详情 + + + - + 去提现 - - - - 我的团队 + + + + + 我的团队 + + - - - + + diff --git a/pages/user/profit/index.js b/pages/user/profit/index.js index 3738ff3..ac7f0c3 100644 --- a/pages/user/profit/index.js +++ b/pages/user/profit/index.js @@ -1,18 +1,43 @@ // pages/user/profit/index.js +const app = getApp() +const user = require('../../../api/user.js') Page({ /** * 页面的初始数据 */ data: { - + userInfo: {}, + integralList: [], + page: 1, + pagesize: 300, + loadingStatus: '没有更多了。。。' }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + this.setData({ + userInfo: wx.getStorageSync('userInfo') + }) + this.getIntegralList() + }, + getIntegralList(){ + let data= { + page: this.data.page, + limit: this.data.pagesize + } + user.getIntegralList(data).then((res)=>{ + this.setData({ + integralList: res.data.data.content + }) + }) + }, + toCashOut(){ + wx.navigateTo({ + url: '/pages/user/cashOut/index?brokeragePrice=' + this.data.userInfo.brokeragePrice, + }) }, /** diff --git a/pages/user/profit/index.wxml b/pages/user/profit/index.wxml index 936c642..aada5c9 100644 --- a/pages/user/profit/index.wxml +++ b/pages/user/profit/index.wxml @@ -2,10 +2,10 @@ - + - 赵铁柱 - ID:2123 + {{userInfo.nickname}} + ID:{{userInfo.uid}} @@ -15,20 +15,31 @@ 今日收益 - 200积分 + {{userInfo.todayBrokerage}}积分 累计收益 - 200积分 + {{userInfo.brokeragePrice}}积分 - 去提现 + 去提现 积分动态 - + + + {{item.title}} + {{item.createTime}} + + + {{item.pm == 0 ? '-' : '+'}}{{item.number}}积分 + {{item.mark}} + + + {{loadingStatus}} + diff --git a/project.private.config.json b/project.private.config.json new file mode 100644 index 0000000..1880f3f --- /dev/null +++ b/project.private.config.json @@ -0,0 +1,17 @@ +{ + "setting": {}, + "condition": { + "plugin": { + "list": [] + }, + "game": { + "list": [] + }, + "gamePlugin": { + "list": [] + }, + "miniprogram": { + "list": [] + } + } +} \ No newline at end of file