diff --git a/app.js b/app.js index df4ab7e..a5f674b 100644 --- a/app.js +++ b/app.js @@ -1,11 +1,34 @@ //app.js + + App({ - onLaunch: function () { + data: { + appId: '' + }, + onLaunch: function() { // 登录 wx.login({ success: res => { - // 发送 res.code 到后台换取 openId, sessionKey, unionId - console.log("login", res); + wx.request({ + url: 'https://ciformall.youlane.cn/C/api/user/login', + header: { + "content-type": "application/json;charset=UTF-8" + }, + data: { + appId: "wx649b3be73c1afe47", + code: res.code + }, + method: 'POST', + success: function(result) { + console.log(result) + } + }) + // Http.postResquest('/api/user/login', '登录中', { + // appId: "wx649b3be73c1afe47", + // code: result.code + // }, (res) => { + // console.log(res) + // }) } }) // 获取用户信息 @@ -38,13 +61,13 @@ App({ /** * 获取地址位置信息 */ - getLocation:function (){ + getLocation: function() { wx.getLocation({ type: 'wgs84', - success: function (res) { + success: function(res) { console.log("getLocation", res); }, - fail:error=>{ + fail: error => { console.log(error); } }) @@ -53,8 +76,12 @@ App({ // 当前用户信息 userInfo: null, // 当前商场信息 - market:{ - name:"陕西大悦城" + market: { + name: "陕西大悦城" } + }, + getAppid() { + let appId = "wx649b3be73c1afe47" + return appId } }) \ No newline at end of file diff --git a/app.json b/app.json index 4a6350e..6a7eeeb 100644 --- a/app.json +++ b/app.json @@ -1,8 +1,9 @@ { "pages": [ + "pages/login/index", + "pages/index/index", + "pages/market/index", "pages/user/index", - "pages/index/index", - "pages/login/index", "pages/coupons/index/index", "pages/coupons/details/index", "pages/order/index/index", @@ -10,8 +11,7 @@ "pages/rushToBuy/index", "pages/shop/index/index", "pages/shop/details/index", - "pages/success/index", - "pages/market/index" + "pages/success/index" ], "tabBar": { "color":"#9F9F9F", diff --git a/components/coupons/index.js b/components/coupons/index.js index 024a9d4..d80a081 100644 --- a/components/coupons/index.js +++ b/components/coupons/index.js @@ -16,11 +16,12 @@ Component({ data: { }, - - /** - * 组件的方法列表 - */ methods: { - + onLogin(e){ + let { id } = e.currentTarget.dataset.date; + wx.navigateTo({ + url: `../../pages/coupons/details/index?id=${id}`, + }) + } } }) diff --git a/components/coupons/index.wxml b/components/coupons/index.wxml index 47a393a..85f9c35 100644 --- a/components/coupons/index.wxml +++ b/components/coupons/index.wxml @@ -1,21 +1,21 @@ - + {{data.name}} - ¥{{data.pPrice}} - ¥{{data.oPrice}} + ¥{{data.price}} + ¥{{data.salePrice}} - {{data.distance}} + {{data.salePrice}} - {{data.address}} + {{data.salePrice}} - 购买 + 购买 \ No newline at end of file diff --git a/pages/coupons/details/index.js b/pages/coupons/details/index.js index daae2ca..7b48508 100644 --- a/pages/coupons/details/index.js +++ b/pages/coupons/details/index.js @@ -1,65 +1,17 @@ -Page({ +let Http = require('../../../utils/http.js') - /** - * 页面的初始数据 - */ +Page({ data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - + list:{} + }, + onLoad(e) { + console.log(this.data) + Http.getResquest('/wxCoupon/findById','加载中',{ + id: e.id + },(res)=>{ + this.setData({ + list: res.data + }) + }) } }) \ No newline at end of file diff --git a/pages/coupons/details/index.wxml b/pages/coupons/details/index.wxml index 55f9155..f1d66a4 100644 --- a/pages/coupons/details/index.wxml +++ b/pages/coupons/details/index.wxml @@ -1 +1,5 @@ -pages/t/index.wxml + + + {{list.subTitle}} + {{list.title}} + diff --git a/pages/index/coupons/index.js b/pages/index/coupons/index.js index fcf3f61..ff01168 100644 --- a/pages/index/coupons/index.js +++ b/pages/index/coupons/index.js @@ -1,4 +1,6 @@ // pages/index/sw/index.js + +let Http = require('../../../utils/http.js') Component({ /** * 组件的属性列表 @@ -99,5 +101,15 @@ Component({ current_scroll: detail.key }); }, + }, + ready(){ + Http.getResquest("/wxCoupon/list",'加载中',{ + "pageNum":1, + "pageSize":10 + },(res)=>{ + this.setData({ + list:res.data.list + }) + }) } }) diff --git a/pages/index/index.js b/pages/index/index.js index 4512bcf..3d4743e 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -14,76 +14,11 @@ Page({ 'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg' ], swiperCurrent: 0, - scrollTop: 0 }, - swiperChange: function (e) { this.setData({ swiperCurrent: e.detail.current }) }, - - //页面滚动执行方式 - onPageScroll(event) { - // console.log(event.scrollTop); - // this.setData({ - // scrollTop: event.scrollTop - // }) - }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } }) diff --git a/pages/login/index.js b/pages/login/index.js index d1b7cc5..7e091c6 100644 --- a/pages/login/index.js +++ b/pages/login/index.js @@ -1,68 +1,14 @@ -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { +let app = getApp() +Page({ + data: { + appId: app.getAppid() }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - + onLoad() { + }, - onLogin: function () { + onLogin: function() { console.log("登陆"); } }) \ No newline at end of file diff --git a/pages/market/index.js b/pages/market/index.js index daae2ca..25235eb 100644 --- a/pages/market/index.js +++ b/pages/market/index.js @@ -1,65 +1,55 @@ Page({ - - /** - * 页面的初始数据 - */ data: { - + tabs: [{ + key: 1, + name: "全部" + }, + { + key: 2, + name: "待付款" + }, + { + key: 3, + name: "已完成" + } + ], + list:[ + { + key:'1', + data:[ + { + name:'111' + } + ] + }, + { + key: '2', + data: [ + { + name: '222' + } + ] + }, + { + key: '3', + data: [ + { + name: '333' + } + ] + } + ], + current:'', + current_scroll:'1' + }, + handleChange({detail}) { + this.setData({ + current: detail.key + }); + }, + handleChangeScroll({detail}) { + this.setData({ + current_scroll: detail.key + }); }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } }) \ No newline at end of file diff --git a/pages/market/index.json b/pages/market/index.json index 423b270..048f980 100644 --- a/pages/market/index.json +++ b/pages/market/index.json @@ -1,6 +1,8 @@ { "usingComponents": { - + "i-tab": "../../dist/tab/index", + "i-tabs": "../../dist/tabs/index", + "c-coupons": "../../components/coupons/index" }, - "navigationBarTitleText": "商场列表" + "navigationBarTitleText": "我的订单" } \ No newline at end of file diff --git a/pages/market/index.wxml b/pages/market/index.wxml index 55f9155..e629c3d 100644 --- a/pages/market/index.wxml +++ b/pages/market/index.wxml @@ -1 +1,33 @@ -pages/t/index.wxml + + + + + + + + + + + + + 黑椒牛排 + 等待付款 + + + 购买数量:1件 + + + 下单时间:2018-07-10 11:30 + + + + + ¥1.00 ¥59.90 + 支付 + + + + + \ No newline at end of file diff --git a/pages/market/index.wxss b/pages/market/index.wxss index e69de29..3025252 100644 --- a/pages/market/index.wxss +++ b/pages/market/index.wxss @@ -0,0 +1,33 @@ +.market{ + width: 100%; +} +.tabs{ + width: 100%!important; + height: 88rpx; + text-align: center; +} +.i-tab{ + width: 30%!important; + display: inline-block; +} +.detail_msg{ + width: 100%; + height: 416rpx!important; + background: #fff; + margin-top: 2%; + display: flex; + flex-direction: column; +} +.detail_msg>view:nth-child(1) { + width: 100%; + height: 244rpx; +} +.detail_msg>view:nth-child(1) view:nth-child(1) { + width: 248rpx; + height: 184rpx; +} +.detail_msg>view:nth-child(1)>view:nth-child(1) image{ + width: 100%; + height: 100%; + margin: 13.2% 0 0 13%; +} \ No newline at end of file diff --git a/project.config.json b/project.config.json index 046a28e..eec3456 100644 --- a/project.config.json +++ b/project.config.json @@ -4,7 +4,7 @@ "ignore": [] }, "setting": { - "urlCheck": true, + "urlCheck": false, "es6": true, "postcss": true, "minified": true, @@ -12,8 +12,8 @@ }, "compileType": "miniprogram", "libVersion": "2.2.2", - "appid": "wxff8123ffb9235426", - "projectname": "wx_luxuriant", + "appid": "wx649b3be73c1afe47", + "projectname": "C", "isGameTourist": false, "condition": { "search": { diff --git a/utils/http.js b/utils/http.js new file mode 100644 index 0000000..7457e34 --- /dev/null +++ b/utils/http.js @@ -0,0 +1,70 @@ +let host = 'https://cinformall.youlane.cn/C'; +let openId="12313213"; +const postResquest = (url, message, postData, doSuccess, doFail) => { + let body={...postData}; + body["openid"] = openId; + if (message != "") { + wx.showLoading({ + title: message, + }) + } + wx.request({ + //项目的真正接口,通过字符串拼接方式实现 + url: host + url, + header: { + "content-type": "application/json;charset=UTF-8" + }, + data: body, + method: 'POST', + success: function (res) { + //参数值为res.data,直接将返回的数据传入 + if (message != "") { + wx.hideLoading() + }; + doSuccess(res.data); + }, + fail: function (res) { + if (message != "") { + wx.hideLoading() + }; + wx.showToast({ + title: '网络错误', + }) + }, + }) +} +const getResquest = (url, message, getData, doSuccess, doFail) => { + let body = { ...getData }; + body["openid"] = openId; + if (message != "") { + wx.showLoading({ + title: message, + }) + } + wx.request({ + url: host + url, + header: { + "content-type": "application/json;charset=UTF-8" + }, + data: body, + method: 'GET', + success: function (res) { + if (message != "") { + wx.hideLoading() + }; + doSuccess(res.data); + }, + fail: function (res) { + if (message != "") { + wx.hideLoading() + }; + wx.showToast({ + title: '网络错误', + }) + }, + }) +} +module.exports = { + postResquest: postResquest, + getResquest: getResquest + } \ No newline at end of file