index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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'}" @click="openAgreement">
  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. <uni-link :href="apkUrl" fontSize="18" text="下载安装包"></uni-link>
  49. </view>
  50. </view>
  51. <u-code ref="uCode" @change="codeChange" seconds="60" @start="disabled1 = true" @end="disabled1 = false"></u-code>
  52. <uni-popup ref="popup" type="center" :animation="false">
  53. ` <view class="agree">
  54. <rich-text v-html="agreement"></rich-text>
  55. </view>
  56. </uni-popup>
  57. </view>
  58. </template>
  59. <script>
  60. export default {
  61. data() {
  62. return {
  63. agreement:'',
  64. apkUrl:'',
  65. disabled1: false,
  66. tips: '',
  67. select:false,
  68. form: {
  69. captchaId:'',
  70. phone: '',
  71. captchaCode: '',
  72. password: '',
  73. password1: '',
  74. inviteCode:''
  75. },
  76. rules: {
  77. 'phone': {
  78. type: 'string',
  79. required: true,
  80. min: 11,
  81. max: 11,
  82. message: '请输入正确的手机号',
  83. trigger: ['blur']
  84. },
  85. 'captchaCode': {
  86. type: 'string',
  87. min: 4,
  88. max: 6,
  89. required: true,
  90. message: '请输入正确的验证码',
  91. trigger: ['blur']
  92. },
  93. 'password': {
  94. type: 'string',
  95. min: 6,
  96. max: 16,
  97. required: true,
  98. message: '请输入6-16位密码',
  99. trigger: ['blur']
  100. },
  101. 'password1': {
  102. type: 'string',
  103. min: 6,
  104. max: 16,
  105. required: true,
  106. message: '请再次输入6-16位密码',
  107. trigger: ['blur']
  108. },
  109. },
  110. }
  111. },
  112. onLoad(e) {
  113. if (e.inviteCode){
  114. console.log(e.inviteCode)
  115. this.form.inviteCode= e.inviteCode
  116. }
  117. this.versionUpgrade()
  118. },
  119. methods: {
  120. openAgreement(){
  121. // this.$refs.popup.open()
  122. },
  123. versionUpgrade(){
  124. this.$api.service.versionUpgrade().then(res=>{
  125. this.apkUrl = res.data.data.apkUrl
  126. // uni.downloadFile({
  127. // url: res.data.data.apkUrl, //仅为示例,并非真实的资源
  128. // success: (res1) => {
  129. //
  130. // console.log('下载返回:',res1)
  131. // console.log('下载成功');
  132. //
  133. //
  134. // }
  135. // })
  136. console.log(res)
  137. })
  138. },
  139. downloadFile(){
  140. uni.downloadFile({
  141. url: 'https://www.example.com/file/test', //仅为示例,并非真实的资源
  142. success: (res) => {
  143. if (res.statusCode === 200) {
  144. console.log('下载成功');
  145. }
  146. }
  147. })
  148. },
  149. selectRead(){
  150. this.select = !this.select
  151. },
  152. register(){
  153. if (!this.select){
  154. uni.$u.toast('请阅读并同意《要酒用户协议》')
  155. return
  156. }
  157. this.$refs.uForm.validate().then(r=>{
  158. this.$api.service.register(this.form).then(res=>{
  159. uni.showToast({
  160. icon: 'success',
  161. duration: 3000,
  162. title: '注册成功!'
  163. });
  164. })
  165. })
  166. },
  167. getCode() {
  168. console.log('6666666666666666666666')
  169. let regExp = new RegExp(this.$phonePattern);
  170. let b = regExp.test(this.form.phone)
  171. if (!b) {
  172. uni.$u.toast('请输入正确的手机号')
  173. return
  174. }
  175. if (this.$refs.uCode.canGetCode) {
  176. // 模拟向后端请求验证码
  177. uni.showLoading({
  178. title: '正在获取验证码'
  179. })
  180. this.$api.service.getSmsCode(this.form).then(res => {
  181. this.form.captchaId= res.data.data.id
  182. uni.hideLoading();
  183. // 这里此提示会被this.start()方法中的提示覆盖
  184. uni.$u.toast('验证码已发送');
  185. // 通知验证码组件内部开始倒计时
  186. this.$refs.uCode.start();
  187. })
  188. } else {
  189. uni.$u.toast('倒计时结束后再发送');
  190. }
  191. },
  192. codeChange(text) {
  193. this.tips = text;
  194. },
  195. }
  196. }
  197. </script>
  198. <style scoped lang="scss">
  199. @import './index.rpx.scss';
  200. </style>