detail.vue 3.8 KB

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