award-information.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. <template>
  2. <view>
  3. <nav-bar title="填写领奖信息" goBack />
  4. <!-- <navbar :config="config" backColor="#999999"></navbar> -->
  5. <view class="info-page">
  6. <view class="info-item">
  7. <view class="info-title">
  8. 领奖人名称:
  9. </view>
  10. <view class="info-value">
  11. <input v-model="formData.receivePrizePersonName" class="info-value-input" placeholder="请输入姓名" />
  12. </view>
  13. </view>
  14. <view class="info-item" v-if="prizeType === 4">
  15. <view class="info-title">
  16. 收获地址:
  17. </view>
  18. <view class="province" @click.stop="areaShow = true">
  19. <view :class="['province-item zw-one-row',formData.receiveProvinceName ? '' : 'input-placeholder']">
  20. {{formData.receiveProvinceName || '请选择'}}
  21. <text class="province-item-icon iconfont_yige">&#xe65f;</text>
  22. </view>
  23. <view :class="['province-item zw-one-row',formData.receiveCityName ? '' : 'input-placeholder']">
  24. {{formData.receiveCityName || '请选择'}}
  25. <text class="province-item-icon iconfont_yige">&#xe65f;</text>
  26. </view>
  27. <view :class="['province-item zw-one-row',formData.receiveAreaName ? '' : 'input-placeholder']">
  28. {{formData.receiveAreaName || '请选择'}}
  29. <text class="province-item-icon iconfont_yige">&#xe65f;</text>
  30. </view>
  31. </view>
  32. <view class="info-value">
  33. <input v-model="formData.receiveAddress" class="info-value-input" placeholder="请输入详细地址" />
  34. </view>
  35. </view>
  36. <view class="info-item">
  37. <view class="info-title">
  38. 领奖人手机号码:
  39. </view>
  40. <view class="info-value">
  41. <input v-model="formData.receivePrizePersonMobile" type="tel" class="info-value-input"
  42. placeholder="请输入电话号码" />
  43. </view>
  44. <view class="info-value">
  45. <input type="tel" v-model="formData.captcha" class="info-value-input" placeholder="请输入验证码" />
  46. <text class="info-value-code" @click.stop="getCode()">{{codeText}}</text>
  47. </view>
  48. </view>
  49. <view class="submit-btn-box">
  50. <view class="submit-btn" @click.stop="onSubmit()">
  51. 确认提交
  52. </view>
  53. </view>
  54. <u-select v-model="areaShow" mode="mutil-column-auto" :list="newProvinceDataList"
  55. @confirm="areaConfirm"></u-select>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. import {
  61. setSupplement
  62. } from "@/api/Lottery.js"
  63. import {
  64. smsCode
  65. } from "@/api/government.js"
  66. export default {
  67. data() {
  68. return {
  69. areaShow: false,
  70. activityJoinRecordId: null,
  71. prizeType: null, // 0谢谢参与,1积分,2优惠券,3线下虚拟商品,4线下实物商品
  72. newProvinceDataList: [],
  73. provinceValue: {
  74. area_name: '',
  75. area_code: ''
  76. },
  77. codeText: "获取验证码",
  78. codeInterval: null,
  79. formData: {
  80. receivePrizePersonMobile: '',
  81. captcha: '',
  82. receivePrizePersonName: '',
  83. receiveProvinceName: '',
  84. receiveProvinceCode: '',
  85. receiveCityName: '',
  86. receiveCityCode: '',
  87. receiveAreaName: '',
  88. receiveAreaCode: '',
  89. receiveAddress: '',
  90. },
  91. submitLoading: false
  92. }
  93. },
  94. onLoad(opt) {
  95. this.activityJoinRecordId = opt.activityJoinRecordId || null;
  96. this.prizeType = Number(opt.prizeType) || null;
  97. // this.prizeType = 4;
  98. this.getAreaList2()
  99. },
  100. methods: {
  101. getCode() {
  102. if (this.codeText === '获取验证码') {
  103. if (!this.formData.receivePrizePersonMobile.match(this.$mConfig.telRegex)) {
  104. this.$mUtil.toast('请输入正确手机号');
  105. return false;
  106. }
  107. try {
  108. clearInterval(this.codeInterval);
  109. this.codeInterval = null;
  110. } catch (e) {
  111. //TODO handle the exception
  112. };
  113. let codeNum = 60;
  114. this.codeInterval = setInterval(() => {
  115. codeNum -= 1
  116. this.codeText = `${codeNum}s`;
  117. if (codeNum <= 0) {
  118. clearInterval(this.codeInterval);
  119. this.codeInterval = null;
  120. this.codeText = "获取验证码"
  121. }
  122. }, 1000);
  123. console.log('请求验证码接口')
  124. smsCode({
  125. mobile: this.formData.receivePrizePersonMobile
  126. }).then(res => {
  127. this.$u.toast('验证码已发送');
  128. }).finally(e => {
  129. uni.hideLoading();
  130. })
  131. }
  132. },
  133. // 获取省市区
  134. getAreaList2() {
  135. let that = this;
  136. let req = this.$http.get('/cnarea/tree-lbs', {});
  137. req.then(res => {
  138. let provincesList = res.tree.children;
  139. let multiIndex = [0, 0, 0];
  140. this.newProvinceDataList = provincesList
  141. })
  142. return req;
  143. },
  144. // 获取地区
  145. areaConfirm(e) {
  146. console.log('areaConfirm = ', e)
  147. if (e.length > 0) {
  148. this.formData.receiveProvinceName = e[0].label;
  149. this.formData.receiveProvinceCode = e[0].value;
  150. this.formData.receiveCityName = e[1].label;
  151. this.formData.receiveCityCode = e[1].value;
  152. this.formData.receiveAreaName = e[2].label;
  153. this.formData.receiveAreaCode = e[2].value;
  154. }
  155. },
  156. onSubmit() {
  157. const params = {}
  158. try {
  159. if (!this.formData.receivePrizePersonName) {
  160. throw new Error('请输入领奖人名称')
  161. }
  162. params.receivePrizePersonName = this.formData.receivePrizePersonName;
  163. if (this.prizeType === 4) {
  164. if (!this.formData.receiveProvinceName) {
  165. throw new Error('请选择省')
  166. }
  167. if (!this.formData.receiveCityName) {
  168. throw new Error('请选择市')
  169. }
  170. if (!this.formData.receiveAreaName) {
  171. throw new Error('请选择区')
  172. }
  173. if (!this.formData.receiveAddress) {
  174. throw new Error('请填写详细地址')
  175. }
  176. params.receiveProvinceName = this.formData.receiveProvinceName;
  177. params.receiveProvinceCode = this.formData.receiveProvinceCode;
  178. params.receiveCityName = this.formData.receiveCityName;
  179. params.receiveCityCode = this.formData.receiveCityCode;
  180. params.receiveAreaName = this.formData.receiveAreaName;
  181. params.receiveAreaCode = this.formData.receiveAreaCode;
  182. params.receiveAddress = this.formData.receiveAddress;
  183. }
  184. if (!this.formData.receivePrizePersonMobile.match(this.$mConfig.telRegex)) {
  185. throw new Error('请输入正确手机号')
  186. }
  187. params.receivePrizePersonMobile = this.formData.receivePrizePersonMobile;
  188. if (!this.formData.captcha || this.formData.captcha.length !== 4) {
  189. throw new Error('请输入验证码')
  190. }
  191. params.captcha = this.formData.captcha;
  192. params.activityJoinRecordId = this.activityJoinRecordId;
  193. this.submitLoading = true
  194. setSupplement(params).then(res => {
  195. uni.showToast({
  196. title: '提交成功',
  197. icon: 'none'
  198. })
  199. try {
  200. const app = getCurrentPages()
  201. const PrevPage = app[app.length - 2]
  202. if (PrevPage && PrevPage.route === "pages/game/winning-list") {
  203. PrevPage.getMyWinningVal()
  204. }
  205. } catch (e) {
  206. //TODO handle the exception
  207. }
  208. setTimeout(() => {
  209. uni.navigateBack()
  210. }, 500)
  211. }).finally(() => {
  212. this.submitLoading = false
  213. })
  214. } catch (e) {
  215. //TODO handle the exception
  216. console.log(e.message)
  217. uni.showToast({
  218. title: e.message,
  219. icon: 'none'
  220. })
  221. }
  222. }
  223. }
  224. }
  225. </script>
  226. <style lang="scss" scoped>
  227. .info-page {
  228. padding: 0 60rpx;
  229. .info-item {
  230. .info-title {
  231. width: 100%;
  232. height: 75rpx;
  233. display: flex;
  234. flex-direction: row;
  235. align-items: flex-end;
  236. font-size: 28rpx;
  237. // font-weight: 300;
  238. text-align: left;
  239. color: #1a1a1a;
  240. }
  241. .province {
  242. padding-top: 20rpx;
  243. width: 100%;
  244. display: flex;
  245. justify-content: space-between;
  246. border-bottom: 1rpx solid #D9D9D9;
  247. .province-item {
  248. width: 32%;
  249. height: 70rpx;
  250. // border: 1rpx solid #ccc;
  251. border-radius: 10rpx;
  252. // display: flex;
  253. position: relative;
  254. // background-color: red;
  255. padding: 0 24rpx 0 10rpx;
  256. line-height: 70rpx;
  257. text-align: center;
  258. font-size: 28rpx;
  259. font-family: PingFang SC, PingFang SC-Light;
  260. color: #666666;
  261. .province-item-icon {
  262. position: absolute;
  263. right: 0;
  264. top: 50%;
  265. transform: translateY(-50%) rotate(90deg);
  266. }
  267. }
  268. }
  269. .info-value {
  270. height: 87rpx;
  271. border-bottom: 1rpx solid #D9D9D9;
  272. display: flex;
  273. align-items: center;
  274. .info-value-input {
  275. flex: 1;
  276. height: 100%;
  277. font-size: 28rpx;
  278. font-size: 28rpx;
  279. font-family: PingFang SC, PingFang SC-Light;
  280. color: #666666;
  281. // background-color: red;
  282. }
  283. .info-value-code {
  284. width: 175rpx;
  285. height: 54rpx;
  286. background: linear-gradient(90deg, #3db8d2 2%, #46c8d5 97%);
  287. border-radius: 27rpx;
  288. text-align: center;
  289. line-height: 54rpx;
  290. font-size: 24rpx;
  291. font-family: PingFang SC, PingFang SC-Regular;
  292. font-weight: 400;
  293. color: #ffffff;
  294. }
  295. }
  296. }
  297. }
  298. .submit-btn-box {
  299. width: 100%;
  300. height: 148rpx;
  301. position: fixed;
  302. left: 0;
  303. bottom: 0;
  304. right: 0;
  305. z-index: 1;
  306. .submit-btn {
  307. width: 690rpx;
  308. height: 80rpx;
  309. background: linear-gradient(92deg, #3cb7d2 2%, #44c5d5 98%);
  310. border-radius: 40rpx;
  311. text-align: center;
  312. line-height: 80rpx;
  313. margin: 34rpx auto;
  314. font-size: 32rpx;
  315. font-family: PingFang SC, PingFang SC-Regular;
  316. font-weight: 400;
  317. text-align: center;
  318. color: #ffffff;
  319. }
  320. }
  321. /deep/ .input-placeholder {
  322. font-size: 28rpx;
  323. color: #cccccc !important;
  324. }
  325. </style>