detail.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <view class="app-container">
  3. <view class="nav" :style="{'padding-top': statusBarHeight + 'px'}">
  4. <uni-icons type="back" style="font-size: 48rpx" @click="getBack" />
  5. <text class="title">积分抽奖</text>
  6. </view>
  7. <uni-forms class="form" ref="form" :modelValue="form" :rules="rules" label-width="100px"
  8. label-position="top" validateTrigger="bind">
  9. <view class="tips">请检查您的信息填写正确,确认后无法更改哦</view>
  10. <uni-forms-item label="收货人:" name="receiveName" required>
  11. <input type="text" v-model="form.receiveName" placeholder="请输入收货人姓名" />
  12. </uni-forms-item>
  13. <uni-forms-item label="手机号:" name="receivePhone" required>
  14. <input type="number" v-model="form.receivePhone" placeholder="请输入手机号" />
  15. </uni-forms-item>
  16. <uni-forms-item label="收货地址:" name="receiveAddress" required>
  17. <textarea v-model="form.receiveAddress" placeholder="请输入收货地址" />
  18. </uni-forms-item>
  19. <button @click="getSubmit" :disabled="disabled">确认</button>
  20. </uni-forms>
  21. </view>
  22. </template>
  23. <script>
  24. import { receive } from '@/api/lottery.js'
  25. export default {
  26. data() {
  27. return {
  28. // 状态栏
  29. statusBarHeight: getApp().globalData.statusBarHeight,
  30. // 表单
  31. form: {},
  32. // 防重复点击
  33. disabled: false,
  34. // 校验
  35. rules: {
  36. receiveName: {
  37. rules: [{
  38. required: true, errorMessage: '请输入收货人姓名'
  39. }]
  40. },
  41. receivePhone: {
  42. rules: [{
  43. required: true, errorMessage: '请输入手机号'
  44. }, {
  45. pattern: /^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\d{8}$/, errorMessage: '请输入正确的手机号'
  46. }]
  47. },
  48. receiveAddress: {
  49. rules: [{
  50. required: true, errorMessage: '请输入收货地址'
  51. }]
  52. }
  53. }
  54. }
  55. },
  56. onLoad(e) {
  57. this.form = {
  58. prizeId: e.prizeId,
  59. lotteryCode: decodeURIComponent(e.lotteryCode)
  60. }
  61. },
  62. methods: {
  63. // 返回
  64. getBack() {
  65. uni.redirectTo({
  66. url: `/pages/lottery/index`
  67. })
  68. },
  69. // 确定
  70. getSubmit() {
  71. this.$refs.form.validate((valid) => {
  72. if (!valid) {
  73. this.disabled = true
  74. receive(getApp().globalData.userInfo, this.form).then(res => {
  75. if (res.data.code === 0) {
  76. uni.showToast({
  77. title: '提交成功!',
  78. duration: 3000
  79. })
  80. setTimeout(() => {
  81. this.getBack()
  82. }, 3000)
  83. } else {
  84. uni.showToast({
  85. icon: 'error',
  86. title: res.data.message,
  87. })
  88. this.disabled = false
  89. }
  90. })
  91. }
  92. })
  93. }
  94. }
  95. }
  96. </script>
  97. <style lang="scss" scoped>
  98. .app-container {
  99. position: relative;
  100. background: url('@/static/lottery/bg-1.png');
  101. background-size: cover;
  102. background-repeat: no-repeat;
  103. width: 100%;
  104. height: 100%;
  105. color: #000;
  106. padding: 0 32rpx 32rpx;
  107. .nav {
  108. height: 88rpx;
  109. display: flex;
  110. align-items: center;
  111. color: #333333;
  112. font-weight: 600;
  113. font-size: 36rpx;
  114. position: relative;
  115. box-sizing: content-box;
  116. .title {
  117. position: absolute;
  118. left: 50%;
  119. transform: translate(-50%);
  120. }
  121. }
  122. .tips {
  123. color: #999;
  124. font-size: 24rpx;
  125. margin-bottom: 32rpx;
  126. }
  127. .form {
  128. margin-top: 32rpx;
  129. height: 1122rpx;
  130. background: #fff;
  131. border-radius: 32rpx;
  132. padding: 32rpx;
  133. position: relative;
  134. .tips {
  135. color: #999;
  136. font-size: 24rpx;
  137. text-align: center;
  138. }
  139. .form-item {
  140. margin: 32rpx 0 0 0;
  141. }
  142. ::v-deep .uni-forms-item__label {
  143. font-size: 32rpx;
  144. font-weight: bold;
  145. padding: 0;
  146. }
  147. input {
  148. border-radius: 16rpx;
  149. height: 88rpx;
  150. line-height: 88rpx;
  151. color: #333333;
  152. margin: 0;
  153. }
  154. uni-textarea {
  155. border-radius: 16rpx;
  156. margin: 0;
  157. }
  158. ::v-deep .input-placeholder, .textarea-placeholder{
  159. opacity: 0.6;
  160. }
  161. button {
  162. background: linear-gradient(180deg, #72cdae 0%, #599f82 100%);
  163. color: #fff;
  164. width: 480rpx;
  165. height: 80rpx;
  166. line-height: 80rpx;
  167. border-radius: 50rpx;
  168. font-size: 32rpx;
  169. position: absolute;
  170. left: 50%;
  171. bottom: 60rpx;
  172. transform: translate(-50%);
  173. }
  174. }
  175. }
  176. </style>