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/goodsDetail/index.wxss b/pages/goodsDetail/index.wxss
index a9ced31..972fcfa 100644
--- a/pages/goodsDetail/index.wxss
+++ b/pages/goodsDetail/index.wxss
@@ -118,4 +118,61 @@
}
.submit-btn{
margin: 0;
+}
+
+.mask-box{
+ width: 100%;
+ height: 100%;
+ background: rgba(0,0,0,.6);
+ position: fixed;
+ top: 0;
+ left: 0;
+}
+.form{
+ position: absolute;
+ top: 50%;
+ left: 50%;
+ transform: translate(-50%,-50%);
+ width: 690rpx;
+ min-height: 370rpx;
+ background: #fff;
+ border-radius: 12rpx;
+ font-size: 24rpx;
+ color: #1D1D1D;
+}
+.form .info-bg{
+ width: 100%;
+ height: 100%;
+ position: absolute;
+ top: 0;
+ left: 0;
+}
+.inp-box{
+ width: 100%;
+ position: absolute;
+ top: 0;
+ left: 0;
+ z-index: 3;
+ padding: 32px 130rpx;
+}
+.inp-item{
+ width: 100%;
+ height: 50rpx;
+ border: 2rpx solid #1D1D1D;
+ border-radius: 8rpx;
+ padding: 0rpx 30rpx;
+ margin-bottom: 40rpx;
+}
+.inp-item input{
+ width: 60%;
+}
+.label{
+ margin-right: 4rpx;
+}
+.submit-btn2{
+ position: absolute;
+ bottom: 46rpx;
+ left: 50%;
+ transform: translateX(-50%);
+ z-index: 3;
}
\ No newline at end of file
diff --git a/pages/goodsList/index.js b/pages/goodsList/index.js
index 620dff3..b3c1b57 100644
--- a/pages/goodsList/index.js
+++ b/pages/goodsList/index.js
@@ -1,22 +1,35 @@
// pages/goodsList/index.js
+const app = getApp()
+const user = require('../../api/user.js')
+const store = require('../../api/store.js')
Page({
-
/**
* 页面的初始数据
*/
data: {
-
+ products: [],
+ loadingStatus: '没有更多了。。。'
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
-
+ console.log(this.data.products)
+ this.getProducts()
+ },
+ //获取产品列表
+ getProducts(){
+ store.getCategory().then((res)=>{
+ this.setData({
+ products: res.data.data[0].children[0].products
+ })
+ })
},
toDetail(e){
+ let id = e.currentTarget.dataset.id
wx.navigateTo({
- url: '/pages/goodsDetail/index',
+ url: '/pages/goodsDetail/index?id=' + id,
})
},
/**
diff --git a/pages/goodsList/index.wxml b/pages/goodsList/index.wxml
index 378eaa3..a9a59a1 100644
--- a/pages/goodsList/index.wxml
+++ b/pages/goodsList/index.wxml
@@ -1,16 +1,17 @@
-
-
+
+
- 瑞梦思·夏季新款独家定制款独家定制智能款独家定制智能智能床垫
- 高级智能床垫·安心休息
+ {{item.storeName}}
+ {{item.storeInfo}}
¥
- 129000
+ {{item.price}}
+ {{loadingStatus}}
diff --git a/pages/goodsList/index.wxss b/pages/goodsList/index.wxss
index aa7ccb8..7d2ed60 100644
--- a/pages/goodsList/index.wxss
+++ b/pages/goodsList/index.wxss
@@ -45,4 +45,9 @@
}
.price .s-word{
font-size: 24rpx;
+}
+.loading-status{
+ text-align: center;
+ font-size: 28rpx;
+ color: #B9B9B9;
}
\ No newline at end of file
diff --git a/pages/home/index.js b/pages/home/index.js
index fac40d0..71fae8e 100644
--- a/pages/home/index.js
+++ b/pages/home/index.js
@@ -1,6 +1,7 @@
// pages/home/index.js
const app = getApp()
const user = require('../../api/user.js')
+const store = require('../../api/store.js')
Page({
/**
@@ -10,8 +11,11 @@ Page({
isAuth: false, //是否认证
authorize: false,
canIUseGetUserProfile: false,
- name: '',
- phone: ''
+ form: {
+ name: '',
+ phone: '',
+ },
+ products: []
},
/**
@@ -19,25 +23,54 @@ Page({
*/
onLoad: function (options) {
// this.getUserInfo()
- console.log(app)
if (wx.getUserProfile) {
this.setData({
canIUseGetUserProfile: true
})
}
- app.globalData.$http()
+ this.getProducts()
+ },
+ //获取产品列表
+ getProducts(){
+ store.getCategory().then((res)=>{
+ this.setData({
+ products: res.data.data[0].children[0].products
+ })
+ app.globalData.products = res.data.data[0].children[0].products
+ })
},
getUserInfoProfile(){
app.login().then((res)=>{
- console.log(res)
+ if(res.data.success){
+ this.setData({
+ isAuth: true
+ })
+ }
+ })
+ },
+ inpName(e){
+ this.setData({
+ 'form.name': e.detail.value
+ })
+ },
+ inpPhone(e){
+ this.setData({
+ 'form.phone': e.detail.value
})
},
submitInfo(){
- if(this.data.name == '' ){
+ if(this.data.form.name == '' ){
return this.alertMessage('请输入您的姓名')
- } else if(this.data.phone == ''){
+ } else if(this.data.form.phone == ''){
return this.alertMessage('请输入您的电话')
}
+ user.saleLeads(this.data.form).then((res)=>{
+ wx.showModal({
+ title: '温馨提示',
+ content: '恭喜您预约成功,稍后会有专属服务老师与您联系。',
+ showCancel: false
+ })
+ })
},
alertMessage(msg){
wx.showToast({
@@ -45,9 +78,10 @@ Page({
icon: 'none'
})
},
- toDetial(){
+ toDetial(e){
+ let id = e.currentTarget.dataset.id
wx.navigateTo({
- url: '/pages/goodsDetail/index',
+ url: '/pages/goodsDetail/index?id='+ id,
})
},
toCompany(){
@@ -55,18 +89,15 @@ Page({
url: '/pages/companyInfo/index',
})
},
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
-
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
-
+ if(wx.getStorageSync('token')){
+ this.setData({
+ isAuth: true
+ })
+ }
},
/**
diff --git a/pages/home/index.wxml b/pages/home/index.wxml
index 03158f9..13b3629 100644
--- a/pages/home/index.wxml
+++ b/pages/home/index.wxml
@@ -19,11 +19,8 @@
商品介绍
-
-
-
-
-
+
+
@@ -36,16 +33,16 @@
您的姓名:
-
+
您的电话:
-
+
-
-
- 立即咨询
+
+
+ 立即预约
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}}人
-
-
- 积分详情
-
-
+
+
+
+ 积分详情
+
+
+