Kaynağa Gözat

静态页面

1002884655 4 yıl önce
ebeveyn
işleme
c167e8a5b2

+ 1
- 1
src/pages/index/DaLeTou/index.vue Dosyayı Görüntüle

@@ -164,7 +164,7 @@ export default {
164 164
         LastSortArr.push({ Num: item, IsDan: false, IsFirst: false })
165 165
       })
166 166
       LastSortArr.sort((a, b) => { return a.Num - b.Num })
167
-      this.AddShuangSeQiuCart({ ...this.ResObj, SortArr: FirstSortArr.concat(LastSortArr), Count: this.TotalResNum, Multiple: 1 })
167
+      this.AddDaLeTouCart({ ...this.ResObj, SortArr: FirstSortArr.concat(LastSortArr), Count: this.TotalResNum, Multiple: 1 })
168 168
       this.FirstList.map((item) => {
169 169
         item.Active = 0
170 170
       })

+ 113
- 27
src/pages/index/DaLeTouDingDan/index.vue Dosyayı Görüntüle

@@ -8,12 +8,6 @@
8 8
             <a class="iconfont iconguanbi Close" @click="DeleteItem(index)"></a>
9 9
             <div class="flex-h">
10 10
               <span class="flex-item">{{ReturnType(item)}}<em>{{item.Count}}</em>注<em>{{item.Count * 2}}</em>元</span>
11
-              <span>
12
-                <a class="iconfont iconjianhao" @click="MultipleLess(item)"></a>
13
-                <input type="number" v-model="item.Multiple" disabled="disabled">
14
-                <span>倍</span>
15
-                <a class="iconfont iconjiahao" @click="MultipleMore(item)"></a>
16
-              </span>
17 11
             </div>
18 12
             <ul>
19 13
               <li v-for="(subItem, subIndex) in item.SortArr" :key="subIndex" :class="{'active': !subItem.IsFirst}">
@@ -27,53 +21,68 @@
27 21
         </ul>
28 22
 
29 23
         <div class="OtherTab">
30
-          <div class="flex-h">
31
-            <span class="flex-item">是否追期?</span>
32
-            <span>追号喜中二等奖</span>
33
-            <van-switch v-model="IsAdd" active-color="#07c160" inactive-color="#ccc" size="0.13rem" @change="SwitchChange" />
24
+          <div>
25
+            <div class="flex-h">
26
+              <span class="flex-item">加倍</span>
27
+              <span>
28
+                <a class="iconfont iconjianhao" @click="Multiple = Multiple > 1 ? Multiple - 1 : 1"></a>
29
+                <input type="number" disabled="disabled" v-model="Multiple">
30
+                <span>倍</span>
31
+                <a class="iconfont iconjiahao" @click="Multiple += 1"></a>
32
+              </span>
33
+            </div>
34
+            <div class="flex-h">
35
+              <span class="flex-item">是否追期?</span>
36
+              <span>追号喜中二等奖</span>
37
+              <van-switch v-model="IsAdd" active-color="#07c160" inactive-color="#ccc" size="0.13rem" @change="SwitchChange" />
38
+            </div>
34 39
           </div>
35 40
         </div>
36 41
 
37 42
       </div>
38 43
     </div>
44
+
39 45
     <div class="Bottom">
40 46
       <div class="Store">
41
-        <a @click="ShowStore = true">店铺:请选择</a>
47
+        <a @click="ShowStore = true">店铺:{{CurrentStoreName || '请选择'}}</a>
42 48
       </div>
43 49
       <div class="Count">
44 50
         <span><em>{{TotalCount}}</em>注</span>
45
-        <span>金额:<em>{{TotalPrize}}</em>元</span>
51
+        <span>金额:<em>{{TotalPrize * Multiple}}</em>元</span>
46 52
       </div>
47
-      <a>立即购买</a>
53
+      <a @click="ToPostBetting" :class="{'active': DaLeTouCart.length}">立即购买</a>
48 54
     </div>
55
+
49 56
     <div class="Layer" v-if="ShowStore">
50 57
       <div class="centerLabel">
51
-        <span>推荐店铺:</span>
52
-        <ul>
53
-          <li v-for="(item, index) in 3" :key="index" class="flex-h">
58
+        <span v-if="RecommendStoreList.length">推荐店铺:</span>
59
+        <ul v-if="RecommendStoreList.length">
60
+          <li v-for="(item, index) in RecommendStoreList" :key="index" v-if="item.status - 0 === 1" class="flex-h" @click="SelectStore(item)">
54 61
             <div class="flex-item">
55 62
               <div>
56
-                <span>彩票供销社{{index + 1}}</span>
63
+                <span>{{item.name}}</span>
57 64
               </div>
58 65
             </div>
59
-            <i class="iconfont iconweigouxuan"></i>
66
+            <i class="iconfont iconweigouxuan" v-if="item.shopId !== CurrentStoreId"></i>
67
+            <i class="iconfont iconyigouxuan active" v-else></i>
60 68
           </li>
61 69
         </ul>
62 70
         <span>选择附近店铺:</span>
63 71
         <ul class="ScrollList">
64
-          <li v-for="(item, index) in 20" :key="index" class="flex-h">
72
+          <li v-for="(item, index) in StoreList" :key="index" v-if="item.status - 0 === 1" class="flex-h" @click="SelectStore(item)">
65 73
             <div class="flex-item">
66 74
               <div>
67
-                <span>彩票供销社{{index + 1}}</span>
75
+                <span>{{item.name}}</span>
68 76
               </div>
69 77
             </div>
70
-            <span>200m</span>
71
-            <i class="iconfont iconweigouxuan"></i>
78
+            <!-- <span>200m</span> -->
79
+            <i class="iconfont iconweigouxuan" v-if="item.shopId !== CurrentStoreId"></i>
80
+            <i class="iconfont iconyigouxuan active" v-else></i>
72 81
           </li>
73 82
         </ul>
74 83
         <div class="Bottom flex-h">
75
-          <a class="flex-item" @click="ShowStore = false">取消</a>
76
-          <a class="flex-item active">确定</a>
84
+          <a class="flex-item" @click="CurrentStoreId = null; CurrentStoreName = null; ShowStore = false">取消</a>
85
+          <a class="flex-item active" @click="ShowStore = false">确定</a>
77 86
         </div>
78 87
       </div>
79 88
     </div>
@@ -83,11 +92,16 @@
83 92
 <script>
84 93
 import { Switch } from 'vant'
85 94
 import { mapMutations, createNamespacedHelpers } from 'vuex'
86
-const { mapState: mapUserState, mapMutations: mapUserMutations } = createNamespacedHelpers('user')
95
+const { mapState: mapUserState, mapActions: mapUserActions, mapMutations: mapUserMutations } = createNamespacedHelpers('user')
87 96
 export default {
88 97
   name: '',
89 98
   data () {
90 99
     return {
100
+      CurrentStoreName: null, // 当前选择店铺名称
101
+      CurrentStoreId: null, // 当前选择店铺id
102
+      RecommendStoreList: [], // 推荐店铺列表
103
+      StoreList: [], // 店铺列表
104
+      Multiple: 1, // 倍数
91 105
       ShowStore: false, // 是否显示店铺选择弹窗
92 106
       TotalCount: 0, // 总注数
93 107
       TotalPrize: 0, // 总金额
@@ -112,6 +126,15 @@ export default {
112 126
     ])
113 127
     this.PageList = [...this.DaLeTouCart]
114 128
     this.CheckOrderCount() // 计算订单倍数、金额
129
+    this.GetStoreList({
130
+      queryData: {
131
+        location: '114.16936109999999,22.3193039',
132
+        lotteryId: 'lottery'
133
+      }
134
+    }).then((res) => {
135
+      this.StoreList = res.data.data.nearest || []
136
+      this.RecommendStoreList = res.data.data.recommend || []
137
+    })
115 138
   },
116 139
   mounted () {
117 140
     this.$nextTick(() => {
@@ -122,8 +145,71 @@ export default {
122 145
       'EditMainData' // 配置页面框架数据
123 146
     ]),
124 147
     ...mapUserMutations([
125
-      'DeleteDaLeTouCart'
148
+      'DeleteDaLeTouCart',
149
+      'EmptyDaLeTouCart'
126 150
     ]),
151
+    ...mapUserActions([
152
+      'PostBetting',
153
+      'GetStoreList'
154
+    ]),
155
+    SelectStore (item) { // 选择店铺
156
+      if (this.DataLock) return
157
+      this.DataLock = true
158
+      this.CurrentStoreName = item.shopId === this.CurrentStoreId ? null : item.name
159
+      this.CurrentStoreId = item.shopId === this.CurrentStoreId ? null : item.shopId
160
+      this.DataLock = false
161
+    },
162
+    ToPostBetting () { // 去下注
163
+      if (this.DataLock) return
164
+      this.DataLock = true
165
+      let ListData = []
166
+      this.DaLeTouCart.map((item) => {
167
+        item.FirstRes.Dan.sort((a, b) => { return a - b })
168
+        item.FirstRes.Tuo.sort((a, b) => { return a - b })
169
+        item.LastRes.Dan.sort((a, b) => { return a - b })
170
+        item.LastRes.Tuo.sort((a, b) => { return a - b })
171
+        ListData.push({
172
+          amount: item.Count, // 购买注数
173
+          charges: this.IsAdd ? item.Count * 3 * 100 : item.Count * 2 * 100, // 价格
174
+          firstDan: item.FirstRes.Dan.join(','), // 前区胆号, 逗号连接
175
+          firstNums: item.FirstRes.Tuo.join(','), // 前区其余数字, 逗号连接
176
+          isDan: !!item.FirstRes.Dan.length, // 是否胆拖
177
+          isMulti: item.Count > 1, // 是否复式
178
+          secondDan: item.LastRes.Dan.join(','), // 后区胆号, 逗号连接
179
+          secondNums: item.LastRes.Tuo.join(',') // 后区其余数字, 逗号连接
180
+        })
181
+      })
182
+      let Data = {
183
+        isAdd: this.IsAdd, // 是否追加, 只有大乐透需要
184
+        issueNo: '123456', // 购买彩票期数,这个你先随便传
185
+        itemList: [...ListData], // 这个是详细购买方案的列表
186
+        lotteryId: 'lottery', // 彩种ID
187
+        notesNum: this.TotalCount, // 总注数
188
+        shopId: this.CurrentStoreId, // 店铺ID
189
+        times: this.Multiple, // 倍数
190
+        totalPrice: this.TotalPrize * this.Multiple * 100 // 总金额
191
+      }
192
+      this.PostBetting({
193
+        urlData: { id: 'lottery' },
194
+        data: { ...Data }
195
+      }).then((res) => {
196
+        this.Dialog.alert({
197
+          message: '投注成功!'
198
+        })
199
+        this.EmptyDaLeTouCart()
200
+        this.PageList = []
201
+        this.TotalCount = 0
202
+        this.TotalPrize = 0
203
+        this.Multiple = 1
204
+        this.DataLock = false
205
+      }).catch((res) => {
206
+        this.Dialog.alert({
207
+          title: '错误',
208
+          message: res.data.message
209
+        })
210
+        this.DataLock = false
211
+      })
212
+    },
127 213
     SwitchChange () { // 追加状态改变
128 214
       this.CheckOrderCount()
129 215
     },
@@ -163,7 +249,7 @@ export default {
163 249
       let ItemPrize = this.IsAdd ? 3 : 2
164 250
       this.PageList.map((item) => {
165 251
         Count += item.Count
166
-        Money += item.Count * item.Multiple * ItemPrize
252
+        Money += item.Count * ItemPrize
167 253
       })
168 254
       this.TotalCount = Count
169 255
       this.TotalPrize = Money

+ 86
- 70
src/pages/index/DaLeTouDingDan/page.scss Dosyayı Görüntüle

@@ -33,7 +33,7 @@
33 33
               display: inline-block;
34 34
               position: absolute;
35 35
               right: 0;
36
-              bottom: 0;
36
+              top: 0;
37 37
               font-size: 0.2rem;
38 38
               color: #999;
39 39
             }
@@ -53,50 +53,10 @@
53 53
                     font-weight: bold;
54 54
                   }
55 55
                 }
56
-                &:last-child {
57
-                  display: inline-block;
58
-                  margin-left: 0.1rem;
59
-                  position: relative;
60
-                  overflow: hidden;
61
-                  border: 0.01rem solid #f7f7f7;
62
-                  border-radius: 0.03rem;
63
-                  font-size: 0;
64
-                  white-space: nowrap;
65
-                  > * {
66
-                    display: inline-block;
67
-                    vertical-align: middle;
68
-                    font-size: 0.14rem;
69
-                    color: #999;
70
-                    line-height: 0.2rem;
71
-                    border-left: 0.01rem solid #f7f7f7;
72
-                    &:first-child {
73
-                      border: none;
74
-                      border-right: 0.01rem solid #f7f7f7;
75
-                    }
76
-                  }
77
-                  > a {
78
-                    width: 0.2rem;
79
-                    text-align: center;
80
-                  }
81
-                  > input {
82
-                    border: none;
83
-                    width: 0.35rem;
84
-                    text-align: center;
85
-                    color: #333;
86
-                    &:disabled {
87
-                      color: #333;
88
-                    }
89
-                  }
90
-                  > span {
91
-                    border: none;
92
-                    margin-right: 0.03rem;
93
-                  }
94
-                }
95 56
               }
96 57
             }
97 58
             > ul {
98 59
               font-size: 0;
99
-              margin-top: 0.1rem;
100 60
               > li {
101 61
                 display: inline-block;
102 62
                 vertical-align: middle;
@@ -130,41 +90,97 @@
130 90
           position: relative;
131 91
           margin-bottom: 0.15rem;
132 92
           > div {
133
-            padding: 0.15rem;
134 93
             background: #fff;
135 94
             border-radius: 0.06rem;
136
-            align-items: center;
137 95
             box-shadow: 0 0 0.02rem 0.02rem rgba(0, 0, 0, 0.05);
138
-            > span {
96
+            > div {
97
+              padding: 0.15rem;
98
+              border-top: 0.01rem solid #f7f7f7;
99
+              align-items: center;
139 100
               &:first-child {
140
-                font-size: 0.15rem;
141
-                color: #666;
142
-                line-height: 0.2rem;
101
+                border-top: none;
102
+              }
103
+              &:nth-child(1) {
104
+                > span {
105
+                  &:nth-child(1) {
106
+                    font-size: 0.15rem;
107
+                    color: #666;
108
+                    line-height: 0.2rem;
109
+                  }
110
+                  &:nth-child(2) {
111
+                    display: inline-block;
112
+                    margin-left: 0.1rem;
113
+                    position: relative;
114
+                    overflow: hidden;
115
+                    border: 0.01rem solid #f7f7f7;
116
+                    border-radius: 0.03rem;
117
+                    font-size: 0;
118
+                    white-space: nowrap;
119
+                    > * {
120
+                      display: inline-block;
121
+                      vertical-align: middle;
122
+                      font-size: 0.14rem;
123
+                      color: #999;
124
+                      line-height: 0.2rem;
125
+                      border-left: 0.01rem solid #f7f7f7;
126
+                      &:first-child {
127
+                        border: none;
128
+                        border-right: 0.01rem solid #f7f7f7;
129
+                      }
130
+                    }
131
+                    > a {
132
+                      width: 0.2rem;
133
+                      text-align: center;
134
+                    }
135
+                    > input {
136
+                      border: none;
137
+                      width: 0.35rem;
138
+                      text-align: center;
139
+                      color: #333;
140
+                      &:disabled {
141
+                        color: #333;
142
+                      }
143
+                    }
144
+                    > span {
145
+                      border: none;
146
+                      margin-right: 0.03rem;
147
+                    }
148
+                  }
149
+                }
143 150
               }
144 151
               &:nth-child(2) {
145
-                font-size: 0.1rem;
146
-                color: #fff;
147
-                display: inline-block;
148
-                position: relative;
149
-                overflow: visible;
150
-                background: #ff5200;
151
-                border-radius: 0.02rem;
152
-                padding: 0 0.05rem;
153
-                line-height: 0.16rem;
154
-                margin-right: 0.1rem;
155
-                &::after {
156
-                  content: "";
157
-                  width: 0;
158
-                  height: 0;
159
-                  border-width: 0.04rem;
160
-                  display: block;
161
-                  position: absolute;
162
-                  right: -0.07rem;
163
-                  top: 50%;
164
-                  transform: translateY(-50%) rotateZ(90deg);
165
-                  -webkit-transform: translateY(-50%) rotateZ(90deg);
166
-                  border-style: solid solid dashed solid;
167
-                  border-color: transparent transparent #ff5200 transparent;
152
+                > span {
153
+                  &:nth-child(1) {
154
+                    font-size: 0.15rem;
155
+                    color: #666;
156
+                    line-height: 0.2rem;
157
+                  }
158
+                  &:nth-child(2) {
159
+                    font-size: 0.1rem;
160
+                    color: #fff;
161
+                    display: inline-block;
162
+                    position: relative;
163
+                    overflow: visible;
164
+                    background: #ff5200;
165
+                    border-radius: 0.02rem;
166
+                    padding: 0 0.05rem;
167
+                    line-height: 0.16rem;
168
+                    margin-right: 0.1rem;
169
+                    &::after {
170
+                      content: "";
171
+                      width: 0;
172
+                      height: 0;
173
+                      border-width: 0.04rem;
174
+                      display: block;
175
+                      position: absolute;
176
+                      right: -0.07rem;
177
+                      top: 50%;
178
+                      transform: translateY(-50%) rotateZ(90deg);
179
+                      -webkit-transform: translateY(-50%) rotateZ(90deg);
180
+                      border-style: solid solid dashed solid;
181
+                      border-color: transparent transparent #ff5200 transparent;
182
+                    }
183
+                  }
168 184
                 }
169 185
               }
170 186
             }

+ 18
- 0
src/store/user/index.js Dosyayı Görüntüle

@@ -4,6 +4,7 @@ import ToolClass from '../../util/PublicMethod'
4 4
 export default {
5 5
   namespaced: true,
6 6
   state: {
7
+    StoreList: [], // 店铺列表
7 8
     PaiLie3Cart: [], // 排列3购物车
8 9
     PaiLie5Cart: [], // 排列5购物车
9 10
     DaLeTouCart: [], // 大乐透购物车
@@ -78,6 +79,13 @@ export default {
78 79
     },
79 80
     EmptyPaiLie5Cart (state, data) { // 清空排列5购物车
80 81
       state.PaiLie5Cart = []
82
+    },
83
+    UpdateStoreList (state, data) { // 更新店铺列表
84
+      let Arr = data.nearest || []
85
+      state.StoreList = []
86
+      Arr.map((item) => {
87
+        state.StoreList.push({ ...item, Active: false })
88
+      })
81 89
     }
82 90
   },
83 91
   actions: {
@@ -85,6 +93,16 @@ export default {
85 93
       return new Promise((resolve, reject) => {
86 94
         ToolClass.Axios(resolve, reject, Api.SignIn, context, payload, 1000, 'UpdateUserInfo')
87 95
       })
96
+    },
97
+    PostBetting (context, payload) { // 下注
98
+      return new Promise((resolve, reject) => {
99
+        ToolClass.Axios(resolve, reject, Api.PostBetting, context, payload, 1000)
100
+      })
101
+    },
102
+    GetStoreList (context, payload) { // 获取店铺列表
103
+      return new Promise((resolve, reject) => {
104
+        ToolClass.Axios(resolve, reject, Api.GetStoreList, context, payload, 1000, 'UpdateStoreList')
105
+      })
88 106
     }
89 107
   }
90 108
 }

+ 8
- 0
src/util/Api.js Dosyayı Görüntüle

@@ -25,6 +25,14 @@ const $api = {
25 25
   GetAllLotteryType: { // 获取所有彩种类型
26 26
     method: 'get',
27 27
     url: `${prefix}/app/lottery`
28
+  },
29
+  PostBetting: { // 下注
30
+    method: 'post',
31
+    url: `${prefix}/app/:id/betting`
32
+  },
33
+  GetStoreList: { // 获取店铺列表
34
+    method: 'get',
35
+    url: `${prefix}/app/shop/available`
28 36
   }
29 37
 }
30 38
 

+ 5
- 0
src/util/PublicMethod.js Dosyayı Görüntüle

@@ -2,6 +2,11 @@
2 2
 import Axios from 'axios'
3 3
 import qs from 'qs'
4 4
 const ToolClass = {
5
+  GetLocation (callabck) {
6
+    if (navigator.geolocation) {
7
+      navigator.geolocation.getCurrentPosition(callabck)
8
+    }
9
+  },
5 10
   TimeOut (callback) {
6 11
     if (window.InitTimer === undefined) window.InitTimer = null
7 12
     window.clearTimeout(window.InitTimer)