作者 cuiyuan

苏杭

@@ -168,6 +168,7 @@ App({ @@ -168,6 +168,7 @@ App({
168 //全局变量 168 //全局变量
169 globalData: { 169 globalData: {
170 userInfo: null, 170 userInfo: null,
171 - cid: null 171 + cid: null,
  172 + class_id: null
172 } 173 }
173 }) 174 })
1 { 1 {
2 "pages": [ 2 "pages": [
3 - "pages/homeindex/homeindex",  
4 "pages/index/index", 3 "pages/index/index",
  4 + "pages/homeindex/homeindex",
  5 +
5 6
6 7
7 8
1 -// pages/homeindex/homeindex.js  
2 const app = getApp() 1 const app = getApp()
3 Page({ 2 Page({
4 3
@@ -8,14 +7,23 @@ Page({ @@ -8,14 +7,23 @@ Page({
8 data: { 7 data: {
9 banner: [], 8 banner: [],
10 shop_class: [], 9 shop_class: [],
11 - middle:'',  
12 - shop:[] 10 + middle: '',
  11 + shop: [],
  12 + num: 1,
  13 + showModal: false,
  14 + class_id: '',
  15 + detailCon: {},
  16 + id: '',
13 }, 17 },
14 look_category(e) { 18 look_category(e) {
  19 + console.log(e)
15 app.globalData.cid = e.currentTarget.dataset.index 20 app.globalData.cid = e.currentTarget.dataset.index
  21 + app.globalData.class_id = e.currentTarget.dataset.class_id
  22 + console.log(app.globalData.cid)
16 wx.switchTab({ 23 wx.switchTab({
17 url: '/pages/kind/kind' 24 url: '/pages/kind/kind'
18 }) 25 })
  26 + this.get_info()
19 }, 27 },
20 // 跳转页面 28 // 跳转页面
21 btn_name() { 29 btn_name() {
@@ -30,19 +38,116 @@ Page({ @@ -30,19 +38,116 @@ Page({
30 'XX-Device-Type': 'wxapp', 38 'XX-Device-Type': 'wxapp',
31 'XX-Token': wx.getStorageSync('token') 39 'XX-Token': wx.getStorageSync('token')
32 } 40 }
33 -  
34 - app.post(url, {}, header).then((res) => { 41 + let params = {
  42 + class_id: that.data.class_id
  43 + }
  44 + console.log(params)
  45 + app.post(url, params, header).then((res) => {
35 console.log(res) 46 console.log(res)
36 that.setData({ 47 that.setData({
37 banner: res.data.banner, 48 banner: res.data.banner,
38 shop_class: res.data.shop_class, 49 shop_class: res.data.shop_class,
39 middle: res.data.middle, 50 middle: res.data.middle,
40 - shop:res.data.shop 51 + shop: res.data.shop,
  52 + now_time: res.data.now_time
41 }) 53 })
  54 + that.countDown()
  55 +
  56 +
42 57
43 }).catch((errMsg) => {}) 58 }).catch((errMsg) => {})
44 59
45 }, 60 },
  61 + goConfirm: function(e) {
  62 +
  63 + this.setData({
  64 + showModal: true,
  65 + index: e.currentTarget.dataset.index
  66 + })
  67 + },
  68 + m_close: function() {
  69 + this.setData({
  70 + showModal: false,
  71 + })
  72 + },
  73 + // 点击加减
  74 + bindMinus: function() {
  75 + var num = this.data.num;
  76 + if (num > 1) {
  77 + num--;
  78 + }
  79 + this.setData({
  80 + num: num,
  81 + });
  82 + },
  83 + // 点击加
  84 + bindPlus: function() {
  85 + var num = this.data.num;
  86 + num++;
  87 + this.setData({
  88 + num: num,
  89 + });
  90 + },
  91 +
  92 + shoptail(e) {
  93 + let id = e.currentTarget.dataset.shop_id;
  94 + wx.navigateTo({
  95 + url: '/pages/kind/detail_1/detail_1?id=' + id,
  96 + })
  97 + },
  98 + // 去团购
  99 + goFirm_order1(e) {
  100 + this.setData({
  101 +
  102 + })
  103 + wx.navigateTo({
  104 + url: '/pages/kind/firm_order1/firm_order1?id=' + e.currentTarget.dataset.id + "&&num=" + this.data.num,
  105 + })
  106 + },
  107 +
  108 + timeFormat(param) { //小于10的格式化函数
  109 + return param < 10 ? '0' + param : param;
  110 + },
  111 + //团购倒计时
  112 + countDown() {
  113 + let that = this
  114 + let objs = Object.assign([], that.data.shop)
  115 + let now_time = parseInt(new Date().getTime())
  116 + // console.log(now_time)
  117 +
  118 + for (let obj of objs) {
  119 +
  120 + let end_time = obj.end_time*1000
  121 + // console.log(end_time)
  122 + let open_time = obj.open_time*1000
  123 + if (now_time < open_time) {
  124 + // console.log(333)
  125 + //活动未开始
  126 + } else if (now_time > end_time) {
  127 + // console.log(222)
  128 + //活动结束
  129 + } else {
  130 + // console.log(1111)
  131 + let time = (end_time - now_time) / 1000;
  132 + let day = parseInt(time / (60 * 60 * 24));
  133 + let hou = parseInt(time % (60 * 60 * 24) / 3600);
  134 + let min = parseInt(time % (60 * 60 * 24) % 3600 / 60);
  135 + let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60);
  136 +
  137 + obj.day = that.timeFormat(day),
  138 + obj.hou = that.timeFormat(hou),
  139 + obj.min = that.timeFormat(min),
  140 + obj.sec = that.timeFormat(sec)
  141 +
  142 + // console.log(obj.day, obj.hou, obj.min, obj.sec)
  143 + }
  144 + }
  145 + that.setData({
  146 + shop: objs
  147 + })
  148 + // console.log(that.data.shop)
  149 + setTimeout(that.countDown, 1000);
  150 + },
46 /** 151 /**
47 * 生命周期函数--监听页面加载 152 * 生命周期函数--监听页面加载
48 */ 153 */
@@ -62,7 +167,15 @@ Page({ @@ -62,7 +167,15 @@ Page({
62 * 生命周期函数--监听页面显示 167 * 生命周期函数--监听页面显示
63 */ 168 */
64 onShow: function() { 169 onShow: function() {
65 - 170 + let that = this
  171 + if (app.globalData.cid != null) {
  172 + that.setData({
  173 + currentTab: app.globalData.cid
  174 + })
  175 + console.log(this.data.aa)
  176 + }
  177 + that.get_info()
  178 + that.countDown()
66 }, 179 },
67 180
68 /** 181 /**
@@ -22,7 +22,7 @@ @@ -22,7 +22,7 @@
22 <view class='commodity'> 22 <view class='commodity'>
23 <!-- <navigator url=''> 23 <!-- <navigator url=''>
24 </navigator> --> 24 </navigator> -->
25 - <view class='jujia' wx:for='{{shop_class}}' wx:key="index" bindtap='look_category' data-index='{{index}}'> 25 + <view class='jujia' wx:for='{{shop_class}}' wx:key="index" data-class_id="{{item.class_id}}" bindtap='look_category' data-index='{{index}}'>
26 <image src='{{item.img}}'></image> 26 <image src='{{item.img}}'></image>
27 <text>{{item.class_name}}</text> 27 <text>{{item.class_name}}</text>
28 </view> 28 </view>
@@ -50,12 +50,12 @@ @@ -50,12 +50,12 @@
50 </view> 50 </view>
51 <view class='container'> 51 <view class='container'>
52 <view class='mid'> 52 <view class='mid'>
53 - <view class='ware_box' wx:for='{{shop}}' wx:key="index"> 53 + <view class='ware_box' bindtap="shoptail" wx:for='{{shop}}' data-shop_id='{{item.shop_id}}' wx:key="index">
54 <view class='ware_top'> 54 <view class='ware_top'>
55 <view class='ware_1'> 55 <view class='ware_1'>
56 <image src='{{item.thumb}}'></image> 56 <image src='{{item.thumb}}'></image>
57 <view class='ware_1_time'> 57 <view class='ware_1_time'>
58 - 据结束2时22分 58 + 据结束{{item.day}}天{{item.hou}}时{{item.min}}分{{item.sec}}秒
59 </view> 59 </view>
60 </view> 60 </view>
61 <view class='ware_text'> 61 <view class='ware_text'>
@@ -64,21 +64,21 @@ @@ -64,21 +64,21 @@
64 <text class='ware_2Txt2'>{{item.origin}}</text> 64 <text class='ware_2Txt2'>{{item.origin}}</text>
65 </view> 65 </view>
66 <view class='ware_3'> 66 <view class='ware_3'>
67 - <progress percent="42" show-info color="#B5DE96" border-radius="8" font-size="24rpx" stroke-width="16rpx" /> 67 + <progress percent="{{item.percent}}" show-info color="#B5DE96" border-radius="8" font-size="24rpx" stroke-width="16rpx" />
68 </view> 68 </view>
69 <view class='ware_4'> 69 <view class='ware_4'>
70 <text>现有{{item.numb}}份,目标{{item.group}}份</text> 70 <text>现有{{item.numb}}份,目标{{item.group}}份</text>
71 </view> 71 </view>
72 <view class='ware_5'> 72 <view class='ware_5'>
73 <view> 73 <view>
74 - <text class='ware5_t1'>{{item.money_sale}}</text> 74 + <text class='ware5_t1'>¥{{item.money_sale}}/</text>
75 <text class='ware5_t2'>{{item.shop_type}}</text> 75 <text class='ware5_t2'>{{item.shop_type}}</text>
76 </view> 76 </view>
77 <view class='ware5_box'> 77 <view class='ware5_box'>
78 <view class='ware5_t3'>{{item.text_table}}</view> 78 <view class='ware5_t3'>{{item.text_table}}</view>
79 <view class='ware5_t4'>{{item.text_content}}</view> 79 <view class='ware5_t4'>{{item.text_content}}</view>
80 </view> 80 </view>
81 - <view class='ware_6'> 81 + <view class='ware_6' data-index="{{index}}" catchtap='goConfirm'>
82 <view>立即参团</view> 82 <view>立即参团</view>
83 </view> 83 </view>
84 </view> 84 </view>
@@ -91,3 +91,34 @@ @@ -91,3 +91,34 @@
91 </view> 91 </view>
92 </view> 92 </view>
93 </view> 93 </view>
  94 +<!-- 弹窗 -->
  95 +<view class="mask" catchtouchmove="preventTouchMove" wx:if="{{showModal}}"></view>
  96 +<!-- 弹出层 -->
  97 +<view class="modalDlg" wx:if="{{showModal}}">
  98 + <view class='modalDlg_p'>
  99 + <view class='m_top'>
  100 + <view class='m_topImg'>
  101 + <image src='{{shop[index].thumb}}'></image>
  102 + </view>
  103 + <view class='m_topTxt'>
  104 + <view class='m_topTxt1'>
  105 + <view class='m_topName'>{{shop[index].name}}</view>
  106 + <image bindtap='m_close' src='../../img/cha.png'></image>
  107 + </view>
  108 + <view class='m_topTxt2'>
  109 + <view class='m_topPrice'>¥{{shop[index].money_sale}}</view>
  110 + <view class='m_topHelf'>{{shop[index].shop_type}}</view>
  111 + </view>
  112 + </view>
  113 + </view>
  114 + <view class='m_number'>
  115 + <view class='m_numTxt'>购买数量</view>
  116 + <view class='minus_push'>
  117 + <view class='minus' bindtap="bindMinus">-</view>
  118 + <view class='num' bindchange="bindManual">{{num}}</view>
  119 + <view class='push' bindtap="bindPlus">+</view>
  120 + </view>
  121 + </view>
  122 + <button class='m_btn' bindtap='goFirm_order1' data-id="{{shop[index].shop_id}}">确认</button>
  123 + </view>
  124 +</view>
1 /* pages/homeindex/homeindex.wxss */ 1 /* pages/homeindex/homeindex.wxss */
2 -.search{ 2 +
  3 +.search {
3 padding: 16rpx 32rpx; 4 padding: 16rpx 32rpx;
4 height: 64rpx; 5 height: 64rpx;
5 - background: #6EAC3D; 6 + background: #6eac3d;
6 display: flex; 7 display: flex;
7 justify-content: center; 8 justify-content: center;
8 align-content: space-between; 9 align-content: space-between;
9 } 10 }
10 -.search_inp{ 11 +
  12 +.search_inp {
11 box-sizing: border-box; 13 box-sizing: border-box;
12 width: 608rpx; 14 width: 608rpx;
13 height: 64rpx; 15 height: 64rpx;
14 border-radius: 32rpx; 16 border-radius: 32rpx;
15 - display:flex; 17 + display: flex;
16 align-items: center; 18 align-items: center;
17 padding-left: 76rpx; 19 padding-left: 76rpx;
18 padding-right: 32rpx; 20 padding-right: 32rpx;
19 - background:#fff; 21 + background: #fff;
20 border: 0; 22 border: 0;
21 outline: none; 23 outline: none;
22 font-size: 26rpx; 24 font-size: 26rpx;
23 position: relative; 25 position: relative;
  26 + color: #666;
24 } 27 }
25 -.search_inp input{ 28 +
  29 +.search_inp input {
26 width: 100%; 30 width: 100%;
27 } 31 }
28 -.search_inp image{ 32 +
  33 +.search_inp image {
29 position: absolute; 34 position: absolute;
30 left: 32rpx; 35 left: 32rpx;
31 top: 17rpx; 36 top: 17rpx;
32 width: 32rpx; 37 width: 32rpx;
33 height: 32rpx; 38 height: 32rpx;
34 } 39 }
35 -.search_txt{ 40 +
  41 +.search_txt {
36 height: 64rpx; 42 height: 64rpx;
37 font-size: 30rpx; 43 font-size: 30rpx;
38 color: #fff; 44 color: #fff;
39 line-height: 64rpx; 45 line-height: 64rpx;
40 padding-left: 16rpx; 46 padding-left: 16rpx;
41 } 47 }
42 -.banner{ 48 +
  49 +.banner {
43 width: 688rpx; 50 width: 688rpx;
44 height: 336rpx; 51 height: 336rpx;
45 margin: 0 auto; 52 margin: 0 auto;
@@ -47,86 +54,101 @@ @@ -47,86 +54,101 @@
47 position: relative; 54 position: relative;
48 border-radius: 8rpx; 55 border-radius: 8rpx;
49 } 56 }
50 -.swiper{ 57 +
  58 +.swiper {
51 height: 100%; 59 height: 100%;
52 position: absolute; 60 position: absolute;
53 z-index: 99; 61 z-index: 99;
54 } 62 }
55 -.swiper-item{ 63 +
  64 +.swiper-item {
56 width: 688rpx; 65 width: 688rpx;
57 margin: 0 auto; 66 margin: 0 auto;
58 height: 336rpx; 67 height: 336rpx;
59 border-radius: 8rpx; 68 border-radius: 8rpx;
60 } 69 }
61 -.swiper-item image{ 70 +
  71 +.swiper-item image {
62 height: auto; 72 height: auto;
63 } 73 }
64 -.banner_Mask{  
65 - width:656rpx; 74 +
  75 +.banner_Mask {
  76 + width: 656rpx;
66 height: 336rpx; 77 height: 336rpx;
67 - background:rgba(181,222,150,1);  
68 - box-shadow:0rpx 6rpx 40rpx rgba(93,255,0,0.44);  
69 - opacity:0.3; 78 + background: rgba(181, 222, 150, 1);
  79 + box-shadow: 0rpx 6rpx 40rpx rgba(93, 255, 0, 0.44);
  80 + opacity: 0.3;
70 position: absolute; 81 position: absolute;
71 bottom: 16rpx; 82 bottom: 16rpx;
72 z-index: -1; 83 z-index: -1;
73 left: 16rpx; 84 left: 16rpx;
74 border-radius: 8rpx; 85 border-radius: 8rpx;
75 } 86 }
76 -.commodity{ 87 +
  88 +.commodity {
77 width: 688rpx; 89 width: 688rpx;
78 /* margin: 0 auto; */ 90 /* margin: 0 auto; */
79 padding: 64rpx 32rpx; 91 padding: 64rpx 32rpx;
80 display: flex; 92 display: flex;
81 - justify-content:space-around; 93 + justify-content: space-around;
82 align-items: center; 94 align-items: center;
83 font-size: 24rpx; 95 font-size: 24rpx;
84 - color: #333333;  
85 - border-bottom: 8px solid rgba(249,250,252,1); 96 + color: #333;
  97 + border-bottom: 8px solid rgba(249, 250, 252, 1);
86 } 98 }
87 -.commodity view{ 99 +
  100 +.commodity view {
88 } 101 }
  102 +
89 .introduce_list { 103 .introduce_list {
90 display: flex; 104 display: flex;
91 justify-content: space-around; 105 justify-content: space-around;
92 align-items: center; 106 align-items: center;
93 padding: 36rpx 32rpx 48rpx 32rpx; 107 padding: 36rpx 32rpx 48rpx 32rpx;
94 } 108 }
95 -.introduce_list .introduce_item{ 109 +
  110 +.introduce_list .introduce_item {
96 display: flex; 111 display: flex;
97 justify-content: space-between; 112 justify-content: space-between;
98 align-items: center; 113 align-items: center;
99 } 114 }
100 -.introduce_list .introduce_item:first-child image{ 115 +
  116 +.introduce_list .introduce_item:first-child image {
101 width: 32rpx; 117 width: 32rpx;
102 height: 36rpx; 118 height: 36rpx;
103 } 119 }
104 -.introduce_list .introduce_item:nth-child(2) image{ 120 +
  121 +.introduce_list .introduce_item:nth-child(2) image {
105 width: 36rpx; 122 width: 36rpx;
106 height: 31rpx; 123 height: 31rpx;
107 } 124 }
108 -.introduce_list .introduce_item:nth-child(3) image{ 125 +
  126 +.introduce_list .introduce_item:nth-child(3) image {
109 width: 32rpx; 127 width: 32rpx;
110 height: 29rpx; 128 height: 29rpx;
111 } 129 }
112 -.introduce_list .introduce_item text{ 130 +
  131 +.introduce_list .introduce_item text {
113 font-size: 28rpx; 132 font-size: 28rpx;
114 display: flex; 133 display: flex;
115 align-items: center; 134 align-items: center;
116 margin-left: 16rpx; 135 margin-left: 16rpx;
117 } 136 }
118 -.introduce image{ 137 +
  138 +.introduce image {
119 width: 668rpx; 139 width: 668rpx;
120 height: 208rpx; 140 height: 208rpx;
121 display: block; 141 display: block;
122 margin: 0 auto; 142 margin: 0 auto;
123 } 143 }
124 -.commodity .jujia image,.commodity .fenlei image{ 144 +
  145 +.commodity .jujia image, .commodity .fenlei image {
125 width: 112rpx; 146 width: 112rpx;
126 height: 112rpx; 147 height: 112rpx;
127 margin: 0 auto; 148 margin: 0 auto;
128 } 149 }
129 -.commodity text{ 150 +
  151 +.commodity text {
130 display: flex; 152 display: flex;
131 margin-top: 14rpx; 153 margin-top: 14rpx;
132 text-align: center; 154 text-align: center;
@@ -134,219 +156,430 @@ @@ -134,219 +156,430 @@
134 align-items: center; 156 align-items: center;
135 } 157 }
136 158
137 -.container{ 159 +.container {
138 width: 750rpx; 160 width: 750rpx;
139 display: flex; 161 display: flex;
140 align-items: center; 162 align-items: center;
141 flex-flow: column; 163 flex-flow: column;
142 } 164 }
143 -.mid{ 165 +
  166 +.mid {
144 margin-top: 16rpx; 167 margin-top: 16rpx;
145 display: flex; 168 display: flex;
146 flex-flow: column; 169 flex-flow: column;
147 } 170 }
148 -.ware_box{  
149 - width:688rpx;  
150 - height:400rpx;  
151 - margin:32rpx auto;  
152 - background:#F9FAFC; 171 +
  172 +.ware_box {
  173 + width: 688rpx;
  174 + height: 400rpx;
  175 + margin: 32rpx auto;
  176 + background: #f9fafc;
153 } 177 }
154 -.ware_top{ 178 +
  179 +.ware_top {
155 overflow: hidden; 180 overflow: hidden;
156 display: flex; 181 display: flex;
157 - padding:32rpx 18rpx 0; 182 + padding: 32rpx 18rpx 0;
158 } 183 }
159 -.ware_1{  
160 - width:312rpx;  
161 - height:208rpx; 184 +
  185 +.ware_1 {
  186 + width: 312rpx;
  187 + height: 208rpx;
162 position: relative; 188 position: relative;
163 } 189 }
164 -.ware_1 image{  
165 - width:100%;  
166 - height:100%; 190 +
  191 +.ware_1 image {
  192 + width: 100%;
  193 + height: 100%;
167 } 194 }
168 -.ware_1_time{ 195 +
  196 +.ware_1_time {
169 position: absolute; 197 position: absolute;
170 - bottom:0;  
171 - width:208rpx;  
172 - height:48rpx; 198 + bottom: 0;
  199 + width: 208rpx;
  200 + height: 48rpx;
173 color: white; 201 color: white;
174 text-align: center; 202 text-align: center;
175 - line-height:48rpx;  
176 - font-size:24rpx;  
177 - background:#FAC8C8;  
178 - font-family:PingFang SC; 203 + line-height: 48rpx;
  204 + font-size: 17rpx;
  205 + background: #fac8c8;
  206 + font-family: PingFang SC;
179 } 207 }
180 -.ware_text{  
181 - margin-left:14rpx;  
182 - width:100%; 208 +
  209 +.ware_text {
  210 + margin-left: 14rpx;
  211 + width: 100%;
183 } 212 }
184 -.ware_2{ 213 +
  214 +.ware_2 {
185 display: flex; 215 display: flex;
186 justify-content: space-between; 216 justify-content: space-between;
187 align-content: center; 217 align-content: center;
188 } 218 }
189 -.ware_2Txt1{  
190 - font-size:32rpx;  
191 - font-family:PingFang SC;  
192 - font-weight:600;  
193 - line-height:44rpx;  
194 - color:rgba(51,51,51,1); 219 +
  220 +.ware_2Txt1 {
  221 + font-size: 32rpx;
  222 + font-family: PingFang SC;
  223 + font-weight: 600;
  224 + line-height: 44rpx;
  225 + color: rgba(51, 51, 51, 1);
195 } 226 }
196 -.ware_2Txt2{  
197 - font-size:22rpx; 227 +
  228 +.ware_2Txt2 {
  229 + font-size: 22rpx;
198 /* margin-left:98rpx; */ 230 /* margin-left:98rpx; */
199 - font-family:PingFang SC;  
200 - font-weight:400;  
201 - line-height:32rpx;  
202 - color:rgba(204,204,204,1);  
203 -}  
204 -.ware_3 progress{  
205 - width:370rpx;  
206 - color:#B5DE96;  
207 - margin-top:24rpx;  
208 -}  
209 -.ware_4 text,.ware5_t2{  
210 - font-size:18rpx;  
211 - font-family:PingFang SC;  
212 - font-weight:400;  
213 - line-height:32rpx;  
214 - color:rgba(204,204,204,1);  
215 -}  
216 -.ware_5{ 231 + font-family: PingFang SC;
  232 + font-weight: 400;
  233 + line-height: 32rpx;
  234 + color: rgba(204, 204, 204, 1);
  235 +}
  236 +
  237 +.ware_3 progress {
  238 + width: 370rpx;
  239 + color: #b5de96;
  240 + margin-top: 24rpx;
  241 +}
  242 +
  243 +.ware_4 text {
  244 + font-size: 22rpx;
  245 + font-family: PingFang SC;
  246 + font-weight: 400;
  247 + line-height: 32rpx;
  248 + color: rgba(204, 204, 204, 1);
  249 +}
  250 +
  251 +.ware5_t2 {
  252 + overflow: hidden;
  253 + text-overflow: ellipsis;
  254 + white-space: nowrap;
  255 + width: 70rpx;
  256 + display: inline-block;
  257 + font-size: 22rpx;
  258 + font-family: PingFang SC;
  259 + font-weight: 400;
  260 + line-height: 19rpx;
  261 + margin-left: 4rpx;
  262 + color: rgba(204, 204, 204, 1);
  263 +}
  264 +
  265 +.ware_5 {
217 display: flex; 266 display: flex;
218 display: -webkit-flex; 267 display: -webkit-flex;
219 justify-content: space-between; 268 justify-content: space-between;
220 } 269 }
221 -.ware5_t1{  
222 - font-size:30rpx;  
223 - font-family:DIN 1451 Std Mittelschrift;  
224 - font-weight:400;  
225 - color:rgba(255,0,0,1);  
226 -}  
227 -.ware5_t3{  
228 - font-size:22rpx;  
229 - font-family:PingFang SC;  
230 - font-weight:400;  
231 - line-height:30rpx;  
232 - color:rgba(51,51,51,1);  
233 -}  
234 -.ware5_t4{  
235 - font-size:18rpx;  
236 - font-family:PingFang SC;  
237 - font-weight:400;  
238 - color:rgba(153,153,153,1);  
239 -}  
240 -.ware_6{  
241 - width:144rpx;  
242 - height:48rpx;  
243 - background:rgba(249,150,20,1);  
244 - box-shadow:0px 2rpx 12rpx rgba(255,145,0,0.16);  
245 - border-radius:24rpx;  
246 -}  
247 -.ware_6 view{  
248 - font-size:26rpx;  
249 - font-family:PingFang SC;  
250 - font-weight:400; 270 +
  271 +.ware5_t1 {
  272 + width: 110rpx;
  273 + overflow: hidden;
  274 + text-overflow: ellipsis;
  275 + white-space: nowrap;
  276 + font-size: 26rpx;
  277 + font-family: DIN 1451 Std Mittelschrift;
  278 + font-weight: 400;
  279 + color: rgba(255, 0, 0, 1);
  280 +}
  281 +
  282 +.ware5_t3 {
  283 + width: 104rpx;
  284 + overflow: hidden;
  285 + text-overflow: ellipsis;
  286 + white-space: nowrap;
  287 + font-size: 20rpx;
  288 + font-family: PingFang SC;
  289 + font-weight: 400;
  290 + line-height: 30rpx;
  291 + color: rgba(51, 51, 51, 1);
  292 +}
  293 +
  294 +.ware5_t4 {
  295 + font-size: 18rpx;
  296 + font-family: PingFang SC;
  297 + font-weight: 400;
  298 + color: rgba(153, 153, 153, 1);
  299 +}
  300 +
  301 +.ware_6 {
  302 + width: 144rpx;
  303 + height: 48rpx;
  304 + background: rgba(249, 150, 20, 1);
  305 + box-shadow: 0px 2rpx 12rpx rgba(255, 145, 0, 0.16);
  306 + border-radius: 24rpx;
  307 +}
  308 +
  309 +.ware_6 view {
  310 + font-size: 26rpx;
  311 + font-family: PingFang SC;
  312 + font-weight: 400;
251 text-align: center; 313 text-align: center;
252 - line-height:48rpx;  
253 - color:rgba(255,255,255,1); 314 + line-height: 48rpx;
  315 + color: rgba(255, 255, 255, 1);
254 } 316 }
255 -.ware_bot{  
256 - width:670rpx;  
257 - height:80rpx; 317 +
  318 +.ware_bot {
  319 + width: 670rpx;
  320 + height: 80rpx;
258 margin: auto; 321 margin: auto;
259 display: flex; 322 display: flex;
260 - line-height:80rpx;  
261 - margin-top:32rpx;  
262 - background-color:#F1F7F1;  
263 -}  
264 -.ware_bot_tit{  
265 - font-size:30rpx;  
266 - font-weight:bold;  
267 - margin-left:32rpx;  
268 - color:rgba(110,172,61,1);  
269 -}  
270 -.ware_bot_tit:after{  
271 - content:"";  
272 - margin:0 38rpx;  
273 - border-right:1px solid #B5DE96;  
274 -}  
275 -.ware_bot_txt{  
276 - font-size:24rpx;  
277 - font-family:PingFang SC;  
278 - font-weight:400;  
279 - color:rgba(153,153,153,1); 323 + line-height: 80rpx;
  324 + margin-top: 32rpx;
  325 + background-color: #f1f7f1;
  326 +}
  327 +
  328 +.ware_bot_tit {
  329 + font-size: 30rpx;
  330 + font-weight: bold;
  331 + margin-left: 32rpx;
  332 + color: rgba(110, 172, 61, 1);
  333 +}
  334 +
  335 +.ware_bot_tit:after {
  336 + content: "";
  337 + margin: 0 38rpx;
  338 + border-right: 1px solid #b5de96;
280 } 339 }
  340 +
  341 +.ware_bot_txt {
  342 + font-size: 24rpx;
  343 + font-family: PingFang SC;
  344 + font-weight: 400;
  345 + color: rgba(153, 153, 153, 1);
  346 +}
  347 +
281 /* 规格 */ 348 /* 规格 */
282 -.spec{  
283 - width:100%;  
284 - padding:0 32rpx;  
285 - line-height:80rpx; 349 +
  350 +.spec {
  351 + width: 100%;
  352 + padding: 0 32rpx;
  353 + line-height: 80rpx;
286 display: flex; 354 display: flex;
287 - height:80rpx;  
288 - margin-top:8rpx;  
289 - background:white;  
290 -}  
291 -.spec_txt{  
292 - font-size:32rpx;  
293 - font-family:PingFang SC;  
294 - font-weight:400;  
295 - color:rgba(51,51,51,1);  
296 -}  
297 -.spec_txt2{  
298 - font-size:24rpx;  
299 - font-family:PingFang SC;  
300 - font-weight:400;  
301 - margin-left:108rpx;  
302 - color:rgba(153,153,153,1); 355 + height: 80rpx;
  356 + margin-top: 8rpx;
  357 + background: white;
303 } 358 }
  359 +
  360 +.spec_txt {
  361 + font-size: 32rpx;
  362 + font-family: PingFang SC;
  363 + font-weight: 400;
  364 + color: rgba(51, 51, 51, 1);
  365 +}
  366 +
  367 +.spec_txt2 {
  368 + font-size: 24rpx;
  369 + font-family: PingFang SC;
  370 + font-weight: 400;
  371 + margin-left: 108rpx;
  372 + color: rgba(153, 153, 153, 1);
  373 +}
  374 +
304 /* 商品详情 */ 375 /* 商品详情 */
305 -.ware_detail{  
306 - width:100%;  
307 - margin-top:8rpx;  
308 - margin-bottom:96rpx;  
309 - padding-bottom:66rpx; 376 +
  377 +.ware_detail {
  378 + width: 100%;
  379 + margin-top: 8rpx;
  380 + margin-bottom: 96rpx;
  381 + padding-bottom: 66rpx;
310 background: white; 382 background: white;
311 } 383 }
312 -.ware_detail_tit{  
313 - width:688rpx; 384 +
  385 +.ware_detail_tit {
  386 + width: 688rpx;
314 margin: auto; 387 margin: auto;
315 display: flex; 388 display: flex;
316 - padding:44rpx 0rpx 42rpx;  
317 - justify-content:space-around;  
318 - border-bottom:2rpx solid #F5F5F5; 389 + padding: 44rpx 0rpx 42rpx;
  390 + justify-content: space-around;
  391 + border-bottom: 2rpx solid #f5f5f5;
319 } 392 }
320 -.ware_detail .ware_active{  
321 - color:#6EAC3D;  
322 - font-weight:600; 393 +
  394 +.ware_detail .ware_active {
  395 + color: #6eac3d;
  396 + font-weight: 600;
323 } 397 }
324 -.ware_active:after{ 398 +
  399 +.ware_active:after {
325 content: ""; 400 content: "";
326 - width:16rpx; 401 + width: 16rpx;
327 height: 6rpx; 402 height: 6rpx;
328 margin: auto; 403 margin: auto;
329 display: block; 404 display: block;
330 - margin-top:6rpx;  
331 - border-radius:8rpx;  
332 - background:rgba(110,172,61,1); 405 + margin-top: 6rpx;
  406 + border-radius: 8rpx;
  407 + background: rgba(110, 172, 61, 1);
  408 +}
  409 +
  410 +.ware_detail_tit view {
  411 + font-size: 28rpx;
  412 + font-family: PingFang SC;
  413 + font-weight: 400;
  414 + color: rgba(153, 153, 153, 1);
  415 +}
  416 +
  417 +.ware_detailC {
  418 + width: 688rpx;
  419 + margin: 26rpx auto 0;
  420 +}
  421 +
  422 +.ware_detailImg {
  423 + width: 688rpx;
  424 + height: 470rpx;
  425 +}
  426 +
  427 +.ware_detailImg image {
  428 + width: 100%;
  429 + height: 100%;
  430 +}
  431 +
  432 +/* 遮罩层 */
  433 +
  434 +.mask {
  435 + width: 100%;
  436 + height: 100%;
  437 + position: fixed;
  438 + top: 0;
  439 + left: 0;
  440 + background: #000;
  441 + z-index: 9000;
  442 + opacity: 0.64;
  443 +}
  444 +
  445 +/* 弹出层 */
  446 +
  447 +.modalDlg {
  448 + width: 100%;
  449 + height: 454rpx;
  450 + bottom: 0;
  451 + position: fixed;
  452 + z-index: 9999;
  453 + background-color: #fff;
  454 +}
  455 +
  456 +.modalDlg_p {
  457 + padding: 0 30rpx;
  458 +}
  459 +
  460 +.m_top {
  461 + display: flex;
  462 +}
  463 +
  464 +.m_topTxt1 {
  465 + display: flex;
  466 + align-self: center;
  467 + justify-content: space-between;
  468 + margin-top: 30rpx;
  469 +}
  470 +
  471 +.m_topTxt {
  472 + width: 100%;
  473 + margin-left: 16rpx;
  474 +}
  475 +
  476 +.m_topImg {
  477 + margin-top: -48rpx;
  478 + display: flex;
333 } 479 }
334 -.ware_detail_tit view{  
335 - font-size:28rpx;  
336 - font-family:PingFang SC;  
337 - font-weight:400;  
338 - color:rgba(153,153,153,1); 480 +
  481 +.m_topImg image {
  482 + width: 208rpx;
  483 + height: 208rpx;
  484 +}
  485 +
  486 +.m_topTxt1 image {
  487 + width: 32rpx;
  488 + height: 32rpx;
  489 +}
  490 +
  491 +.m_topName {
  492 + font-size: 32rpx;
  493 + font-family: PingFang SC;
  494 + font-weight: 600;
  495 + color: rgba(51, 51, 51, 1);
  496 +}
  497 +
  498 +.m_topTxt2 {
  499 + display: flex;
  500 + margin-top: 16rpx;
  501 + align-items: center;
  502 +}
  503 +
  504 +.m_topPrice {
  505 + width: 120rpx;
  506 + overflow: hidden;
  507 + text-overflow: ellipsis;
  508 + white-space: nowrap;
  509 + font-size: 28rpx;
  510 + font-family: DIN 1451 Std Mittelschrift;
  511 + font-weight: 400;
  512 + color: #f00;
  513 +}
  514 +
  515 +.m_topHelf {
  516 + width: 280rpx;
  517 + overflow: hidden;
  518 + text-overflow: ellipsis;
  519 + white-space: nowrap;
  520 + font-size: 22rpx;
  521 + font-family: PingFang SC;
  522 + font-weight: 400;
  523 + margin-left: 16rpx;
  524 + color: rgba(204, 204, 204, 1);
339 } 525 }
340 -.ware_detailC{  
341 - width:688rpx;  
342 - margin:26rpx auto 0; 526 +
  527 +.m_number {
  528 + display: flex;
  529 + align-items: center;
  530 + margin-top: 18rpx;
343 } 531 }
344 532
345 -.ware_detailImg{  
346 - width:688rpx;  
347 - height:470rpx; 533 +.minus_push {
  534 + display: flex;
  535 + margin-left: auto;
  536 + align-items: center;
  537 +}
  538 +
  539 +.m_numTxt {
  540 + font-size: 24rpx;
  541 + font-family: PingFang SC;
  542 + font-weight: 400;
  543 + color: rgba(153, 153, 153, 1);
  544 +}
  545 +
  546 +.minus, .push {
  547 + width: 48rpx;
  548 + height: 48rpx;
  549 + font-size: 40rpx;
  550 + text-align: center;
  551 + line-height: 48rpx;
  552 + border: 2px solid rgba(110, 172, 61, 1);
  553 + border-radius: 50%;
348 } 554 }
349 -.ware_detailImg image{  
350 - width:100%;  
351 - height:100%; 555 +
  556 +.minus {
  557 + color: #6eac3d;
  558 +}
  559 +
  560 +.num {
  561 + margin: 0 26rpx;
  562 + font-size: 32rpx;
  563 + font-family: PingFang SC;
  564 + font-weight: 400;
  565 + color: rgba(110, 172, 61, 1);
  566 +}
  567 +
  568 +.push {
  569 + color: white;
  570 + background: rgba(110, 172, 61, 1);
  571 +}
  572 +
  573 +.m_btn {
  574 + width: 688rpx;
  575 + height: 80rpx;
  576 + border: 0;
  577 + margin-top: 62rpx;
  578 + font-size: 32rpx;
  579 + font-family: PingFang SC;
  580 + font-weight: 600;
  581 + color: rgba(255, 255, 255, 1);
  582 + background: linear-gradient(170deg, rgba(181, 222, 150, 1) 0%, rgba(169, 209, 33, 1) 100%);
  583 + box-shadow: 0rpx 6rpx 40rpx rgba(162, 255, 0, 0.15);
  584 + border-radius: 48rpx;
352 } 585 }
@@ -9,7 +9,10 @@ Page({ @@ -9,7 +9,10 @@ Page({
9 recommend: [], 9 recommend: [],
10 history: [], 10 history: [],
11 keyword: '', 11 keyword: '',
12 - page:'' 12 + page: '',
  13 + type: true,
  14 + dis:true
  15 +
13 }, 16 },
14 17
15 /** 18 /**
@@ -40,14 +43,30 @@ Page({ @@ -40,14 +43,30 @@ Page({
40 recommend: res.data.recommend, 43 recommend: res.data.recommend,
41 history: res.data.history 44 history: res.data.history
42 }) 45 })
  46 + that.countDown()
43 47
44 }).catch((errMsg) => { 48 }).catch((errMsg) => {
45 49
46 }) 50 })
47 51
48 }, 52 },
  53 + exchange(e){
  54 + let keyword=this.data.keyword
  55 + console.log(e)
  56 + this.setData({
  57 + keyword: e._relatedInfo.anchorTargetText
  58 + })
  59 + },
49 info(event) { 60 info(event) {
50 let that = this 61 let that = this
  62 + if (that.data.keyword == '') {
  63 + wx.showToast({
  64 + title: '商品名称不能为空',
  65 + icon: 'none',
  66 + duration: 1000
  67 + })
  68 + return false
  69 + }
51 // 接口地址 70 // 接口地址
52 let url = app.interface.shopPage 71 let url = app.interface.shopPage
53 let header = { 72 let header = {
@@ -57,37 +76,156 @@ Page({ @@ -57,37 +76,156 @@ Page({
57 76
58 77
59 let keyword = this.data.keyword 78 let keyword = this.data.keyword
  79 +
60 app.post(url, { 80 app.post(url, {
61 page: 1, 81 page: 1,
62 keyword: keyword 82 keyword: keyword
63 },header).then((res) => { 83 },header).then((res) => {
64 that.setData({ 84 that.setData({
65 - shop: res.data.shop 85 + shop: res.data.shop,
  86 + type:false,
  87 + dis: false,
  88 + keyword: ''
66 }) 89 })
  90 + that.get_info()
67 }).catch((errMsg) => { 91 }).catch((errMsg) => {
68 92
69 }) 93 })
70 }, 94 },
  95 +
  96 + cansle(){
  97 + console.log(111)
  98 + this.setData({
  99 + type:true,
  100 + dis: true
  101 + })
  102 + },
  103 + display() {
  104 + this.setData({
  105 + dis: false
  106 + })
  107 + },
71 clear(){ 108 clear(){
72 let that =this 109 let that =this
  110 + wx.showModal({
  111 + title: '提示',
  112 + content: '确认删除全部历史记录',
  113 + success(res) {
  114 + if (res.confirm) {
  115 + console.log('用户点击确定')
73 let url = app.interface.historyDelete 116 let url = app.interface.historyDelete
74 let header = { 117 let header = {
75 'XX-Device-Type': 'wxapp', 118 'XX-Device-Type': 'wxapp',
76 'XX-Token': wx.getStorageSync('token') 119 'XX-Token': wx.getStorageSync('token')
77 } 120 }
78 app.post(url, {}, header).then((res) => { 121 app.post(url, {}, header).then((res) => {
79 - console.log(history) 122 +
80 123
81 that.setData({ 124 that.setData({
82 history: [] 125 history: []
83 }) 126 })
84 - console.log(111)  
85 127
86 128
  129 + console.log(111)
  130 +
87 }).catch((errMsg) => { 131 }).catch((errMsg) => {
88 132
89 }) 133 })
  134 + } else if (res.cancel) {
  135 + console.log('用户点击取消')
  136 + }
  137 + }
  138 + })
  139 +
  140 +
  141 +
  142 +
  143 + },
  144 + timeFormat(param) { //小于10的格式化函数
  145 + return param < 10 ? '0' + param : param;
  146 + },
  147 + //团购倒计时
  148 + countDown() {
  149 + let that = this
  150 + let objs = Object.assign([], that.data.shop)
  151 + let now_time = parseInt(new Date().getTime())
  152 + // console.log(now_time)
  153 +
  154 + for (let obj of objs) {
  155 +
  156 + let end_time = obj.end_time*1000
  157 + // console.log(end_time)
  158 + let open_time = obj.open_time*1000
  159 + if (now_time < open_time) {
  160 + // console.log(333)
  161 + //活动未开始
  162 + } else if (now_time > end_time) {
  163 + // console.log(222)
  164 + //活动结束
  165 + } else {
  166 + // console.log(1111)
  167 + let time = (end_time - now_time) / 1000;
  168 + let day = parseInt(time / (60 * 60 * 24));
  169 + let hou = parseInt(time % (60 * 60 * 24) / 3600);
  170 + let min = parseInt(time % (60 * 60 * 24) % 3600 / 60);
  171 + let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60);
  172 +
  173 + obj.day = that.timeFormat(day),
  174 + obj.hou = that.timeFormat(hou),
  175 + obj.min = that.timeFormat(min),
  176 + obj.sec = that.timeFormat(sec)
  177 +
  178 + // console.log(obj.day, obj.hou, obj.min, obj.sec)
  179 + }
  180 + }
  181 + that.setData({
  182 + shop: objs
  183 + })
  184 + // console.log(that.data.shop)
  185 + setTimeout(that.countDown, 1000);
  186 + },
  187 + timeFormat(param) { //小于10的格式化函数
  188 + return param < 10 ? '0' + param : param;
  189 + },
  190 + //团购倒计时
  191 + countDown() {
  192 + let that = this
  193 + let objs = Object.assign([], that.data.shop)
  194 + let now_time = parseInt(new Date().getTime())
  195 + // console.log(now_time)
  196 +
  197 + for (let obj of objs) {
90 198
  199 + let end_time = obj.end_time * 1000
  200 + // console.log(end_time)
  201 + let open_time = obj.open_time * 1000
  202 + if (now_time < open_time) {
  203 + // console.log(333)
  204 + //活动未开始
  205 + } else if (now_time > end_time) {
  206 + // console.log(222)
  207 + //活动结束
  208 + } else {
  209 + // console.log(1111)
  210 + let time = (end_time - now_time) / 1000;
  211 + let day = parseInt(time / (60 * 60 * 24));
  212 + let hou = parseInt(time % (60 * 60 * 24) / 3600);
  213 + let min = parseInt(time % (60 * 60 * 24) % 3600 / 60);
  214 + let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60);
  215 +
  216 + obj.day = that.timeFormat(day),
  217 + obj.hou = that.timeFormat(hou),
  218 + obj.min = that.timeFormat(min),
  219 + obj.sec = that.timeFormat(sec)
  220 +
  221 + // console.log(obj.day, obj.hou, obj.min, obj.sec)
  222 + }
  223 + }
  224 + that.setData({
  225 + shop: objs
  226 + })
  227 + // console.log(that.data.shop)
  228 + setTimeout(that.countDown, 1000);
91 }, 229 },
92 add(){ 230 add(){
93 231
@@ -103,6 +241,7 @@ Page({ @@ -103,6 +241,7 @@ Page({
103 * 生命周期函数--监听页面显示 241 * 生命周期函数--监听页面显示
104 */ 242 */
105 onShow: function() { 243 onShow: function() {
  244 + that.countDown()
106 245
107 }, 246 },
108 247
@@ -2,41 +2,44 @@ @@ -2,41 +2,44 @@
2 <!-- <text>pages/homeindex/search/search.wxml</text> --> 2 <!-- <text>pages/homeindex/search/search.wxml</text> -->
3 <view class='search'> 3 <view class='search'>
4 <view class='search_inp'> 4 <view class='search_inp'>
5 - <input type='text' placeholder='请输入商品名称' maxlength='12' bindinput='bindKeyInput' value='{{keyword}}'></input> 5 + <input type='text' placeholder='请输入商品名称' maxlength='12' bindinput='bindKeyInput' value='{{keyword}}' ></input>
6 <image src='../../../img/search.png'></image> 6 <image src='../../../img/search.png'></image>
7 </view> 7 </view>
8 - <view class='search_txt' bindtap='info'> 8 + <view class='search_txt' bindtap='info' wx:if='{{type}}'>
9 搜索 9 搜索
10 </view> 10 </view>
  11 + <view class='search_txt' bindtap='cansle' wx:else>
  12 + 取消
  13 + </view>
11 </view> 14 </view>
12 -<view class='Popular'> 15 +<view class='Popular' wx:if='{{dis}}'>
13 <view class='Popular_title'> 16 <view class='Popular_title'>
14 <text>热门搜索</text> 17 <text>热门搜索</text>
15 <image src='../../../img/zuire@3x.png'></image> 18 <image src='../../../img/zuire@3x.png'></image>
16 </view> 19 </view>
17 <view class='Popular_list' > 20 <view class='Popular_list' >
18 - <view class='Popular_item' wx:for='{{recommend}}' wx:key> 21 + <view class='Popular_item' bindtap='exchange' data-word='{{recommend[index]}}' wx:for='{{recommend}}' wx:key>
19 {{recommend[index]}} 22 {{recommend[index]}}
20 </view> 23 </view>
21 24
22 </view> 25 </view>
23 - <view class='History'> 26 + <view class='History' wx:if='{{history.length > 0}}'>
24 <view class='History_title'>历史搜索 27 <view class='History_title'>历史搜索
25 <image src='../../../img/del.png' bindtap='clear'></image> 28 <image src='../../../img/del.png' bindtap='clear'></image>
26 </view> 29 </view>
27 <view class='History_list'> 30 <view class='History_list'>
28 - <view class='History_item' wx:for='{{history}}' wx:key>{{history[index]}}</view> 31 + <view class='History_item' bindtap='exchange' wx:for='{{history}}' wx:key>{{history[index]}}</view>
29 </view> 32 </view>
30 </view> 33 </view>
31 </view> 34 </view>
32 -<view class='container'> 35 +<view class='container' bindtap='display' wx:else>
33 <view class='mid'> 36 <view class='mid'>
34 <view class='ware_box' wx:for='{{shop}}' wx:key="index"> 37 <view class='ware_box' wx:for='{{shop}}' wx:key="index">
35 <view class='ware_top'> 38 <view class='ware_top'>
36 <view class='ware_1'> 39 <view class='ware_1'>
37 <image src='{{item.thumb}}'></image> 40 <image src='{{item.thumb}}'></image>
38 <view class='ware_1_time'> 41 <view class='ware_1_time'>
39 - 据结束2时22分 42 + 据结束{{item.day}}天{{item.hou}}时{{item.min}}分{{item.sec}}秒
40 </view> 43 </view>
41 </view> 44 </view>
42 <view class='ware_text'> 45 <view class='ware_text'>
@@ -45,7 +48,7 @@ @@ -45,7 +48,7 @@
45 <text class='ware_2Txt2'>{{item.origin}}</text> 48 <text class='ware_2Txt2'>{{item.origin}}</text>
46 </view> 49 </view>
47 <view class='ware_3'> 50 <view class='ware_3'>
48 - <progress percent="42" show-info color="#B5DE96" border-radius="8" font-size="24rpx" stroke-width="16rpx" /> 51 + <progress percent="{{item.percent}}" show-info color="#B5DE96" border-radius="8" font-size="24rpx" stroke-width="16rpx" />
49 </view> 52 </view>
50 <view class='ware_4'> 53 <view class='ware_4'>
51 <text>现有{{item.numb}}份,目标{{item.group}}份</text> 54 <text>现有{{item.numb}}份,目标{{item.group}}份</text>
@@ -72,7 +75,7 @@ @@ -72,7 +75,7 @@
72 </view> 75 </view>
73 76
74 </view> 77 </view>
75 - <view wx:if="{{shop.length == 0}}">暂无更多结果</view> 78 + <view class='empty' wx:if="{{shop.length == 0}}">暂无更多结果</view>
76 79
77 80
78 </view> 81 </view>
@@ -136,7 +136,7 @@ @@ -136,7 +136,7 @@
136 color: white; 136 color: white;
137 text-align: center; 137 text-align: center;
138 line-height:48rpx; 138 line-height:48rpx;
139 - font-size:24rpx; 139 + font-size:18rpx;
140 background:#FAC8C8; 140 background:#FAC8C8;
141 font-family:PingFang SC; 141 font-family:PingFang SC;
142 } 142 }
@@ -313,3 +313,9 @@ @@ -313,3 +313,9 @@
313 width:100%; 313 width:100%;
314 height:100%; 314 height:100%;
315 } 315 }
  316 +.empty{
  317 + font-size: 32rpx;
  318 + margin-top: 120px;
  319 + text-align: center;
  320 + color: #ccc;
  321 +}
@@ -4,108 +4,112 @@ const app = getApp() @@ -4,108 +4,112 @@ const app = getApp()
4 4
5 Page({ 5 Page({
6 data: { 6 data: {
7 - session_key:'',  
8 - openid:''  
9 - },  
10 -  
11 -  
12 7
13 - /**  
14 - * 生命周期函数--监听页面加载  
15 - */  
16 - onLoad: function (options) {  
17 - this.getLoginFun();  
18 }, 8 },
19 9
20 - // 获取session_key  
21 - getLoginFun() {  
22 - let that = this; 10 + getOpenId() {
  11 + let that = this
23 wx.login({ 12 wx.login({
24 - success: function (s) {  
25 - console.log(s);  
26 - wx.setStorageSync("token", 123123);  
27 -  
28 - let url = 'wxapp/public/getSessionKey';  
29 - if (s.code) {  
30 - var code = s.code;  
31 - var param = {  
32 - code: s.code 13 + success: (res) => {
  14 + let url = 'wxapp/public/getSessionKey'
  15 + let param = {
  16 + code: res.code,
33 } 17 }
  18 +
34 app.post(url, param).then((res) => { 19 app.post(url, param).then((res) => {
35 - console.log(res);  
36 that.setData({ 20 that.setData({
37 openid: res.data.openid, 21 openid: res.data.openid,
38 session_key: res.data.session_key 22 session_key: res.data.session_key
39 }) 23 })
40 - // res.data = {} 24 + wx.getSetting({
  25 + success: res => {
  26 + if (res.authSetting['scope.userInfo'] === true) {
  27 + wx.getUserInfo({
  28 + success: reg => {
  29 + that.setData({
  30 + encrypted_data: reg.encryptedData,
  31 + iv: reg.iv
  32 + })
  33 + that.login()
  34 + }
  35 + })
  36 + }
  37 +
  38 + }
  39 + })
41 40
42 }).catch((errMsg) => { 41 }).catch((errMsg) => {
43 - console.log(errMsg);  
44 }) 42 })
45 - } 43 +
  44 +
46 } 45 }
47 }); 46 });
48 }, 47 },
49 48
50 - // 获取用户信息 49 + // 获取用户权限信息
51 getUserInfo(e) { 50 getUserInfo(e) {
52 - console.log(e); 51 + let that = this;
  52 + if (e.detail.errMsg == "getUserInfo:ok") {
  53 + that.setData({
  54 + encrypted_data: e.detail.encryptedData,
  55 + iv: e.detail.iv
  56 + })
  57 + that.login()
  58 + }
  59 +
53 60
  61 + },
  62 +
  63 + // 登录
  64 + login() {
  65 + let that = this;
54 let url = "wxapp/public/login"; 66 let url = "wxapp/public/login";
55 let data = { 67 let data = {
56 - openid: this.data.openid,  
57 - session_key: this.data.session_key,  
58 - encrypted_data: e.detail.encryptedData,  
59 - iv: e.detail.iv, 68 + openid: that.data.openid,
  69 + session_key: that.data.session_key,
  70 + encrypted_data: that.data.encrypted_data,
  71 + iv: that.data.iv,
60 } 72 }
61 app.post(url, data).then((res) => { 73 app.post(url, data).then((res) => {
62 - console.log(res);  
63 wx.setStorageSync("token", res.data.token); 74 wx.setStorageSync("token", res.data.token);
  75 + wx.showLoading({
  76 + title: '正在进入',
  77 + })
  78 +
  79 + let t = setInterval(function() {
  80 + clearInterval(t)
64 wx.switchTab({ 81 wx.switchTab({
65 url: '../homeindex/homeindex', 82 url: '../homeindex/homeindex',
66 }) 83 })
  84 + wx.hideLoading()
  85 + }, 1500)
  86 +
67 }).catch((err) => { 87 }).catch((err) => {
68 - console.log(err); 88 +
69 }) 89 })
  90 +
  91 +
  92 +
  93 + // }).catch((errMsg) => { })
  94 +
70 }, 95 },
71 96
72 97
73 98
74 99
75 - // start(e) { 100 + // 111
  101 + /**
  102 + * 生命周期函数--监听页面加载
  103 + */
  104 + onLoad: function(options) {
  105 + this.getOpenId();
  106 + },
  107 +
  108 +
76 109
77 - // let that = this;  
78 - // console.log(e)  
79 110
80 - // // app.globalData.userInfo = e.detail.userInfo  
81 - // wx.login({  
82 - // success: (res) => {  
83 - // console.log(res)  
84 - // let url = '/api/portal/common/getToken';  
85 - // let params = {  
86 - // code: res.code,  
87 - // user_nickname: e.detail.userInfo.nickName,  
88 - // avatar: e.detail.userInfo.avatarUrl  
89 - // // user_nickname: e.detail.userInfo.nickName,  
90 - // // avatar: e.detail.userInfo.avatarUrl //分享进入的需要此参数  
91 - // }  
92 - // app.post(url, params).then((res) => {  
93 - // console.log('999', res)  
94 - // wx.setStorageSync('token', res.token);  
95 111
96 - // wx.navigateTo({  
97 - // url: "/pages/mainindex/mainindex",  
98 - // })  
99 112
100 - // // wx.switchTab({  
101 - // // url: '../mainindex/mainindex',  
102 - // // })  
103 113
104 - // }).catch((errMsg) => {  
105 - // // console.log(errMsg)  
106 - // })  
107 114
108 - // }  
109 - // });  
110 - // },  
111 }) 115 })
@@ -29,7 +29,6 @@ Page({ @@ -29,7 +29,6 @@ Page({
29 this.assessFun() 29 this.assessFun()
30 }, 30 },
31 goFirm_order1(e) { 31 goFirm_order1(e) {
32 -  
33 wx.navigateTo({ 32 wx.navigateTo({
34 url: '../firm_order1/firm_order1?id=' + e.currentTarget.dataset.id + "&&num=" + this.data.num, 33 url: '../firm_order1/firm_order1?id=' + e.currentTarget.dataset.id + "&&num=" + this.data.num,
35 }) 34 })
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 <text class='ware_2Txt2'>产地:{{detailCon.origin}}</text> 15 <text class='ware_2Txt2'>产地:{{detailCon.origin}}</text>
16 </view> 16 </view>
17 <view class='ware_3'> 17 <view class='ware_3'>
18 - <progress percent="42" show-info color="#B5DE96" border-radius="8" font-size="24rpx" stroke-width="16rpx" /> 18 + <progress percent="{{item.percent}}" show-info color="#B5DE96" border-radius="8" font-size="24rpx" stroke-width="16rpx" />
19 </view> 19 </view>
20 <view class='ware_4'> 20 <view class='ware_4'>
21 <text>已拼{{detailCon.numb}}份,目标{{detailCon.group}}份</text> 21 <text>已拼{{detailCon.numb}}份,目标{{detailCon.group}}份</text>
@@ -54,13 +54,56 @@ Page({ @@ -54,13 +54,56 @@ Page({
54 54
55 shoptail(e){ 55 shoptail(e){
56 console.log(e) 56 console.log(e)
57 - let id=e.currentTarget.dataset.shop_id; 57 + let id= e.currentTarget.dataset.shop_id;
58 console.log(id) 58 console.log(id)
59 wx.navigateTo({ 59 wx.navigateTo({
60 - url: 'detail_1/detail_1?id='+id, 60 + url: 'detail_1/detail_1?id=' + id,
61 }) 61 })
62 62
63 }, 63 },
  64 + timeFormat(param) { //小于10的格式化函数
  65 + return param < 10 ? '0' + param : param;
  66 + },
  67 + //团购倒计时
  68 + countDown() {
  69 + let that = this
  70 + let objs = Object.assign([], that.data.shop)
  71 + let now_time = parseInt(new Date().getTime())
  72 + // console.log(now_time)
  73 +
  74 + for (let obj of objs) {
  75 +
  76 + let end_time = obj.end_time * 1000
  77 + // console.log(end_time)
  78 + let open_time = obj.open_time * 1000
  79 + if (now_time < open_time) {
  80 + // console.log(333)
  81 + //活动未开始
  82 + } else if (now_time > end_time) {
  83 + // console.log(222)
  84 + //活动结束
  85 + } else {
  86 + // console.log(1111)
  87 + let time = (end_time - now_time) / 1000;
  88 + let day = parseInt(time / (60 * 60 * 24));
  89 + let hou = parseInt(time % (60 * 60 * 24) / 3600);
  90 + let min = parseInt(time % (60 * 60 * 24) % 3600 / 60);
  91 + let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60);
  92 +
  93 + obj.day = that.timeFormat(day),
  94 + obj.hou = that.timeFormat(hou),
  95 + obj.min = that.timeFormat(min),
  96 + obj.sec = that.timeFormat(sec)
  97 +
  98 + // console.log(obj.day, obj.hou, obj.min, obj.sec)
  99 + }
  100 + }
  101 + that.setData({
  102 + shop: objs
  103 + })
  104 + // console.log(that.data.shop)
  105 + setTimeout(that.countDown, 1000);
  106 + },
64 /** 107 /**
65 * 生命周期函数--监听页面初次渲染完成 108 * 生命周期函数--监听页面初次渲染完成
66 */ 109 */
@@ -76,12 +119,11 @@ Page({ @@ -76,12 +119,11 @@ Page({
76 if (app.globalData.cid != null){ 119 if (app.globalData.cid != null){
77 that.setData({ 120 that.setData({
78 currentTab: app.globalData.cid, 121 currentTab: app.globalData.cid,
79 - aa: 123 122 + class_id: app.globalData.class_id
80 }) 123 })
81 - console.log(this.data.aa)  
82 } 124 }
83 that.get_info() 125 that.get_info()
84 - 126 + that.countDown()
85 }, 127 },
86 128
87 /** 129 /**
@@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
11 <view class='ware_1' data-categoryid="{{item.shop_id}}"> 11 <view class='ware_1' data-categoryid="{{item.shop_id}}">
12 <image src='{{item.thumb}}'></image> 12 <image src='{{item.thumb}}'></image>
13 <view class='ware_1_time'> 13 <view class='ware_1_time'>
14 - 据结束2时22分 14 + 据结束{{item.day}}天{{item.hou}}时{{item.min}}分{{item.sec}}秒
15 </view> 15 </view>
16 </view> 16 </view>
17 <view class='ware_text'> 17 <view class='ware_text'>
@@ -20,14 +20,14 @@ @@ -20,14 +20,14 @@
20 <text class='ware_2Txt2'>{{item.origin}}</text> 20 <text class='ware_2Txt2'>{{item.origin}}</text>
21 </view> 21 </view>
22 <view class='ware_3'> 22 <view class='ware_3'>
23 - <progress percent="42" show-info color="#B5DE96" border-radius="8" font-size="24rpx" stroke-width="16rpx" /> 23 + <progress percent="{{item.percent}}" show-info color="#B5DE96" border-radius="8" font-size="24rpx" stroke-width="16rpx" />
24 </view> 24 </view>
25 <view class='ware_4'> 25 <view class='ware_4'>
26 <text>现有{{item.numb}}份,目标{{item.group}}份</text> 26 <text>现有{{item.numb}}份,目标{{item.group}}份</text>
27 </view> 27 </view>
28 <view class='ware_5'> 28 <view class='ware_5'>
29 <view> 29 <view>
30 - <text class='ware5_t1'>{{item.money_sale}}</text> 30 + <text class='ware5_t1'>¥{{item.money_sale}}/</text>
31 <text class='ware5_t2'>{{item.shop_type}}</text> 31 <text class='ware5_t2'>{{item.shop_type}}</text>
32 </view> 32 </view>
33 <view class='ware5_box'> 33 <view class='ware5_box'>
@@ -47,4 +47,5 @@ @@ -47,4 +47,5 @@
47 </view> 47 </view>
48 48
49 </view> 49 </view>
  50 + <view class='empty' wx:if="{{shop.length == 0}}">暂无更多结果</view>
50 </view> 51 </view>
@@ -78,7 +78,7 @@ @@ -78,7 +78,7 @@
78 color: white; 78 color: white;
79 text-align: center; 79 text-align: center;
80 line-height:48rpx; 80 line-height:48rpx;
81 - font-size:24rpx; 81 + font-size:18rpx;
82 background:#FAC8C8; 82 background:#FAC8C8;
83 font-family:PingFang SC; 83 font-family:PingFang SC;
84 } 84 }
@@ -118,16 +118,33 @@ @@ -118,16 +118,33 @@
118 line-height:32rpx; 118 line-height:32rpx;
119 color:rgba(204,204,204,1); 119 color:rgba(204,204,204,1);
120 } 120 }
  121 +.ware5_t2 {
  122 + overflow:hidden;
  123 + text-overflow:ellipsis;
  124 + white-space:nowrap;
  125 + width:70rpx;
  126 + display: inline-block;
  127 + font-size: 22rpx;
  128 + font-family: PingFang SC;
  129 + font-weight: 400;
  130 + line-height: 19rpx;
  131 + margin-left:4rpx;
  132 + color: rgba(204, 204, 204, 1);
  133 +}
121 .ware_5{ 134 .ware_5{
122 display: flex; 135 display: flex;
123 display: -webkit-flex; 136 display: -webkit-flex;
124 justify-content: space-between; 137 justify-content: space-between;
125 } 138 }
126 -.ware5_t1{  
127 - font-size:30rpx;  
128 - font-family:DIN 1451 Std Mittelschrift;  
129 - font-weight:400;  
130 - color:rgba(255,0,0,1); 139 +.ware5_t1 {
  140 + width:110rpx;
  141 + overflow:hidden;
  142 + text-overflow:ellipsis;
  143 + white-space:nowrap;
  144 + font-size:26rpx;
  145 + font-family: DIN 1451 Std Mittelschrift;
  146 + font-weight: 400;
  147 + color: rgba(255, 0, 0, 1);
131 } 148 }
132 .ware5_t3{ 149 .ware5_t3{
133 font-size:22rpx; 150 font-size:22rpx;
@@ -149,13 +166,13 @@ @@ -149,13 +166,13 @@
149 box-shadow:0px 2rpx 12rpx rgba(255,145,0,0.16); 166 box-shadow:0px 2rpx 12rpx rgba(255,145,0,0.16);
150 border-radius:24rpx; 167 border-radius:24rpx;
151 } 168 }
152 -.ware_6 view{  
153 - font-size:26rpx;  
154 - font-family:PingFang SC;  
155 - font-weight:400; 169 +.ware_6 view {
  170 + font-size: 26rpx;
  171 + font-family: PingFang SC;
  172 + font-weight: 400;
156 text-align: center; 173 text-align: center;
157 - line-height:48rpx;  
158 - color:rgba(255,255,255,1); 174 + line-height: 48rpx;
  175 + color: rgba(255, 255, 255, 1);
159 } 176 }
160 .ware_bot{ 177 .ware_bot{
161 width:670rpx; 178 width:670rpx;
@@ -255,3 +272,9 @@ @@ -255,3 +272,9 @@
255 width:100%; 272 width:100%;
256 height:100%; 273 height:100%;
257 } 274 }
  275 +.empty{
  276 + font-size: 32rpx;
  277 + margin-top: 120px;
  278 + text-align: center;
  279 + color: #ccc;
  280 +}
@@ -35,6 +35,7 @@ Page({ @@ -35,6 +35,7 @@ Page({
35 status: 0, 35 status: 0,
36 toCancel: false 36 toCancel: false
37 }, 37 },
  38 +
38 /** 39 /**
39 * 生命周期函数--监听页面加载 40 * 生命周期函数--监听页面加载
40 */ 41 */
@@ -12,9 +12,9 @@ @@ -12,9 +12,9 @@
12 "autoAudits": false 12 "autoAudits": false
13 }, 13 },
14 "compileType": "miniprogram", 14 "compileType": "miniprogram",
15 - "libVersion": "2.6.1",  
16 - "appid": "wx1f51f42105b63343",  
17 - "projectname": "shop-suh", 15 + "libVersion": "2.6.2",
  16 + "appid": "wxd577c8d542ca150e",
  17 + "projectname": "teamshop",
18 "debugOptions": { 18 "debugOptions": {
19 "hidedInDevtools": [] 19 "hidedInDevtools": []
20 }, 20 },