index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <view class="page">
  3. <image class="bg" :src="'/static/img/bg1.jpg'"></image>
  4. <view class="content">
  5. <view>
  6. <u--form labelPosition="left" :model="form" :rules="rules" ref="uForm">
  7. <view class="flex-col justify-center inputView">
  8. <u-form-item prop="phone" ref="item1">
  9. <u-input v-model="form.phone" placeholder="请输入手机号" placeholderStyle="color:#333333" border="none"></u-input>
  10. </u-form-item>
  11. </view>
  12. <view class="flex-col justify-center inputView">
  13. <u-form-item prop="captchaCode" ref="item1">
  14. <u-input v-model="form.captchaCode" placeholder="请输入验证码" placeholderStyle="color:#333333" border="none"></u-input>
  15. <text class="tips" @click="getCode" >{{tips}}</text>
  16. </u-form-item>
  17. </view>
  18. <view class="flex-col justify-center inputView">
  19. <u-form-item prop="password" ref="item1">
  20. <u-input v-model="form.password" placeholder="请输入您的密码" placeholderStyle="color:#333333" border="none"></u-input>
  21. </u-form-item>
  22. </view>
  23. <view class="flex-col justify-center inputView">
  24. <u-form-item prop="password1" ref="item1">
  25. <u-input v-model="form.password1" placeholder="请再次输入您的密码" placeholderStyle="color:#333333" border="none"></u-input>
  26. </u-form-item>
  27. </view>
  28. <view class="flex-col justify-center inputView inputView1">
  29. <u-form-item prop="inviteCode" ref="item1">
  30. <u-input v-model="form.inviteCode" placeholder="请输入邀请码" placeholderStyle="color:#333333" border="none"></u-input>
  31. </u-form-item>
  32. </view>
  33. </u--form>
  34. </view>
  35. <view class="flex-row justify-center read">
  36. <view class="icon">
  37. <u-icon :name="'/static/img/xuanzhong.png'" size="16" v-if="select" @click="selectRead"></u-icon>
  38. <u-icon :name="'/static/img/weixuanzhong.png'" size="16" v-else @click="selectRead"></u-icon>
  39. </view>
  40. <text :style="{'margin-left':'10rpx'}">
  41. 我已阅读并同意《要酒用户协议》
  42. </text>
  43. </view>
  44. <view class="zcbtn" @click="register">注册</view>
  45. <view class="xiazai">
  46. <text >注册完成:</text>
  47. <text class="xiazaiText" @click="versionUpgrade">下载安装包</text>
  48. </view>
  49. </view>
  50. <u-code ref="uCode" @change="codeChange" seconds="60" @start="disabled1 = true" @end="disabled1 = false"></u-code>
  51. </view>
  52. </template>
  53. <script>
  54. export default {
  55. data() {
  56. return {
  57. disabled1: false,
  58. tips: '',
  59. select:false,
  60. form: {
  61. captchaId:'',
  62. phone: '',
  63. captchaCode: '',
  64. password: '',
  65. password1: '',
  66. inviteCode:''
  67. },
  68. rules: {
  69. 'phone': {
  70. type: 'string',
  71. required: true,
  72. min: 11,
  73. max: 11,
  74. message: '请输入正确的手机号',
  75. trigger: ['blur']
  76. },
  77. 'captchaCode': {
  78. type: 'string',
  79. min: 4,
  80. max: 6,
  81. required: true,
  82. message: '请输入正确的验证码',
  83. trigger: ['blur']
  84. },
  85. 'password': {
  86. type: 'string',
  87. min: 6,
  88. max: 16,
  89. required: true,
  90. message: '请输入6-16位密码',
  91. trigger: ['blur']
  92. },
  93. 'password1': {
  94. type: 'string',
  95. min: 6,
  96. max: 16,
  97. required: true,
  98. message: '请再次输入6-16位密码',
  99. trigger: ['blur']
  100. },
  101. },
  102. }
  103. },
  104. onLoad() {
  105. },
  106. methods: {
  107. versionUpgrade(){
  108. this.$api.service.versionUpgrade().then(res=>{
  109. console.log(res)
  110. })
  111. },
  112. downloadFile(){
  113. uni.downloadFile({
  114. url: 'https://www.example.com/file/test', //仅为示例,并非真实的资源
  115. success: (res) => {
  116. if (res.statusCode === 200) {
  117. console.log('下载成功');
  118. }
  119. }
  120. })
  121. },
  122. selectRead(){
  123. this.select = !this.select
  124. },
  125. register(){
  126. if (!this.select){
  127. uni.$u.toast('请阅读并同意《要酒用户协议》')
  128. return
  129. }
  130. this.$refs.uForm.validate().then(r=>{
  131. this.$api.service.register(this.form).then(res=>{
  132. uni.showToast({
  133. icon: 'success',
  134. duration: 3000,
  135. title: '注册成功!'
  136. });
  137. })
  138. })
  139. },
  140. getCode() {
  141. console.log('6666666666666666666666')
  142. let regExp = new RegExp(this.$phonePattern);
  143. let b = regExp.test(this.form.phone)
  144. if (!b) {
  145. uni.$u.toast('请输入正确的手机号')
  146. return
  147. }
  148. if (this.$refs.uCode.canGetCode) {
  149. // 模拟向后端请求验证码
  150. uni.showLoading({
  151. title: '正在获取验证码'
  152. })
  153. this.$api.service.getSmsCode(this.form).then(res => {
  154. this.form.captchaId= res.data.data.id
  155. uni.hideLoading();
  156. // 这里此提示会被this.start()方法中的提示覆盖
  157. uni.$u.toast('验证码已发送');
  158. // 通知验证码组件内部开始倒计时
  159. this.$refs.uCode.start();
  160. })
  161. } else {
  162. uni.$u.toast('倒计时结束后再发送');
  163. }
  164. },
  165. codeChange(text) {
  166. this.tips = text;
  167. },
  168. }
  169. }
  170. </script>
  171. <style>
  172. .page {
  173. width: 100vw;
  174. height: 100vh;
  175. position: relative;
  176. }
  177. .bg {
  178. width: 100%;
  179. height: 100%;
  180. }
  181. .content {
  182. width: 100vw;
  183. position: absolute;
  184. bottom: 100rpx;
  185. left: 0;
  186. }
  187. .inputView {
  188. width: 646rpx;
  189. min-height: 50rpx;
  190. background: white;
  191. margin-top: 20rpx;
  192. margin-left: 32rpx;
  193. border-radius: 15rpx;
  194. overflow: hidden;
  195. padding: 10rpx 20rpx;
  196. }
  197. .inputView1 {
  198. background-color: rgba(255, 255, 255, 0.5)
  199. }
  200. .tips {
  201. color: #b63a3a;
  202. }
  203. .zcbtn{
  204. background: #fed09e;
  205. width: 686rpx;
  206. height: 80rpx;
  207. border-radius: 40rpx;
  208. text-align: center;
  209. color: #bc372b;
  210. line-height: 80rpx;
  211. font-size: 36rpx;
  212. margin-top: 20rpx;
  213. margin-left: 32rpx;
  214. }
  215. .read{
  216. color: white;
  217. font-size: 22rpx;
  218. margin-top: 20rpx;
  219. }
  220. .icon{
  221. margin-top: 5rpx;
  222. }
  223. .xiazai{
  224. width: 686rpx;
  225. margin-top: 20rpx;
  226. margin-left: 32rpx;
  227. font-size: 26rpx;
  228. }
  229. .xiazaiText{
  230. color: #007aff;
  231. }
  232. </style>