reg.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <template>
  2. <view class="page">
  3. <view class="header">
  4. <view class="left">
  5. <!-- <image class="img" mode="widthFix" src="../../static/login/close.png"></image> -->
  6. </view>
  7. </view>
  8. <view class="tbody">
  9. <view>
  10. <image class="img" mode="widthFix" src="../../static/logo.png"></image>
  11. </view>
  12. <!-- <view class="name">昵称:</view>
  13. <view class="item">
  14. <input type="text" class="input" v-model="nickname" maxlength="30" placeholder="请输入您的昵称" />
  15. </view> -->
  16. <view class="name">手机号码:</view>
  17. <view class="item">
  18. <input type="text" class="input" v-model="mobile" maxlength="11" placeholder="请输入手机号码" />
  19. </view>
  20. <view class="name">验证码:</view>
  21. <view class="item">
  22. <input type="text" class="input" v-model="code" maxlength="6" placeholder="请输入验证码" />
  23. <view class="btn" v-if="captchaTime === 0" @click="getCode">获取验证码</view>
  24. <view class="btn" v-if="captchaTime > 0">{{captchaTime}}秒后重试</view>
  25. </view>
  26. <view class="name">登录密码:</view>
  27. <view class="item">
  28. <input type="password" class="input" v-model="password" maxlength="50" placeholder="请输入登录密码" />
  29. </view>
  30. <view class="name">确认密码:</view>
  31. <view class="item">
  32. <input type="password" class="input" v-model="password2" maxlength="50" placeholder="请再次输入登录密码" />
  33. </view>
  34. <view class="other_list">
  35. <text class="left" v-if="false">忘记密码</text>
  36. <text class="left" v-else></text>
  37. <text class="right" @click="goPage('/pages/login/login')">已有账号?去登录</text>
  38. </view>
  39. <view class="agree">
  40. <view class="agree2" @click="agreeChk()">
  41. <image mode="widthFix" src="../../static/login/sel_no.png" v-if="is_agree == 0"></image>
  42. <image mode="widthFix" src="../../static/login/sel_yes.png" v-if="is_agree == 1"></image>
  43. <text>我已阅读并同意</text>
  44. </view>
  45. <text class="xy" @click="goPage('yhxy')">
  46. 隐私协议
  47. </text>
  48. 》和《
  49. <text class="xy" @click="goPage('yszc')">
  50. 用户使用协议
  51. </text>
  52. </view>
  53. <text class="btn_submit" @click="toReg">注册</text>
  54. </view>
  55. <view class="blankHeight"></view>
  56. <!-- 提示框 -->
  57. <DialogBox ref="DialogBox"></DialogBox>
  58. </view>
  59. </template>
  60. <script>
  61. import pubc from '@/common/public.js'
  62. export default {
  63. components: {},
  64. data() {
  65. return {
  66. title: '',
  67. sel: 1,
  68. is_agree: 0,
  69. mobile: '',
  70. password: '',
  71. password2: '',
  72. code: '',
  73. ycode: '',
  74. nickname: '',
  75. captchaTime: 0,
  76. is_web3: 0,
  77. push_token: '',
  78. lat: '',
  79. lng: '',
  80. }
  81. },
  82. onLoad(params) {
  83. this.ycode = params.ycode || '111111';
  84. this.is_web3 = this.$isWeb3;
  85. setTimeout(function() {
  86. uni.setNavigationBarColor({
  87. frontColor: '#ffffff',
  88. backgroundColor: '#00000000',
  89. animation: {
  90. duration: 400,
  91. timingFunc: 'easeIn'
  92. }
  93. })
  94. }, 200);
  95. let that = this;
  96. // #ifdef APP-PLUS
  97. uni.getPushClientId({
  98. success: (res) => {
  99. console.log("su:", res.cid);
  100. that.push_token = res.cid;
  101. },
  102. fail(err) {
  103. that.push_token = '';
  104. console.log(err)
  105. }
  106. });
  107. // #endif
  108. },
  109. onShow() {
  110. let that = this;
  111. // #ifdef APP-PLUS
  112. // uni.getLocation({
  113. // type: 'wgs84',
  114. // success: function(res) {
  115. // that.lat = res.latitude;
  116. // that.lng = res.longitude;
  117. // },
  118. // fail: function(error) {
  119. // console.error('获取位置失败:', error);
  120. // }
  121. // });
  122. // #endif
  123. },
  124. methods: {
  125. onBack() {},
  126. agreeChk() {
  127. if (this.is_agree == 0) {
  128. this.is_agree = 1;
  129. } else {
  130. this.is_agree = 0;
  131. }
  132. },
  133. getCodeTime() {
  134. this.captchaTime = 60;
  135. let timer = setInterval(() => {
  136. this.captchaTime--;
  137. // console.log(this.captchaTime)
  138. if (this.captchaTime < 1) {
  139. clearInterval(timer);
  140. this.captchaTime = 0
  141. }
  142. }, 1000)
  143. },
  144. getCode() {
  145. if (this.mobile.length != 11) {
  146. uni.showToast({
  147. title: '请输入手机号',
  148. icon: 'none'
  149. });
  150. return;
  151. }
  152. if (this.captchaTime > 0) {
  153. uni.showToast({
  154. title: '不能重复获取',
  155. icon: 'none'
  156. });
  157. return;
  158. }
  159. this.captchaTime = 60;
  160. uni.request({
  161. url: this.$apiHost + '/Web/getcode', //仅为示例,并非真实接口地址。
  162. data: {
  163. skey: this.skey,
  164. mobile: this.mobile,
  165. },
  166. header: {
  167. 'content-type': 'application/json' //自定义请求头信息
  168. },
  169. success: (res) => {
  170. console.log("----", res.data)
  171. uni.showToast({
  172. title: res.data.str,
  173. icon: 'none'
  174. })
  175. if (res.data.success == 'yes') {
  176. this.getCodeTime();
  177. } else {
  178. this.captchaTime = 0;
  179. }
  180. }
  181. });
  182. },
  183. goPage(page) {
  184. if (page == 'yhxy') {
  185. uni.navigateTo({
  186. url: '/pages/AboutUs/yhxy'
  187. })
  188. } else if (page == 'yszc') {
  189. uni.navigateTo({
  190. url: '/pages/AboutUs/yszc'
  191. })
  192. } else {
  193. uni.navigateTo({
  194. url: page,
  195. });
  196. }
  197. },
  198. toReg() {
  199. if (this.is_agree == 0) {
  200. uni.showToast({
  201. title: "请确认并选择协议",
  202. icon: "none",
  203. });
  204. return;
  205. }
  206. if (this.mobile.length != 11) {
  207. uni.showToast({
  208. title: "请输入手机号",
  209. icon: "none",
  210. });
  211. return;
  212. }
  213. if (this.password.length < 6) {
  214. uni.showToast({
  215. title: "请输入不小于6位的密码",
  216. icon: "none",
  217. });
  218. return;
  219. }
  220. if (this.password != this.password2) {
  221. uni.showToast({
  222. title: "两次输入密码不一致",
  223. icon: "none",
  224. });
  225. return;
  226. }
  227. if (this.code.length < 4) {
  228. uni.showToast({
  229. title: "请输入手机验证码",
  230. icon: "none",
  231. });
  232. return;
  233. }
  234. let method = '/Web/reg';
  235. uni.showLoading({
  236. mask: true,
  237. });
  238. console.log("host", this.$apiHost + method);
  239. uni.request({
  240. url: this.$apiHost + method, //仅为示例,并非真实接口地址。
  241. data: {
  242. uuid: getApp().globalData.uuid,
  243. // nickname: this.nickname,
  244. mobile: this.mobile,
  245. password: this.password,
  246. ycode: this.ycode,
  247. code: this.code,
  248. is_web3: this.is_web3,
  249. push_token: this.push_token,
  250. lat: this.lat,
  251. lng: this.lng,
  252. },
  253. header: {
  254. "content-type": "application/json"
  255. },
  256. success: (res) => {
  257. console.log("----", res.data);
  258. if (res.data.success == "yes") {
  259. // #ifdef APP-PLUS
  260. uni.setStorageSync("wapptoken", res.data.skey);
  261. getApp().globalData.skey = res.data.skey;
  262. if (res.data.header_c != "") {
  263. getApp().globalData.headerSign = pubc.Encrypt(res.data.header_c + "_" +
  264. getApp().globalData.uuid);
  265. uni.setStorageSync("headerSign", getApp().globalData.headerSign);
  266. }
  267. getApp().globalData.headerC = res.data.header_c;
  268. uni.redirectTo({
  269. url: '/pages/my/step'
  270. });
  271. // uni.switchTab({
  272. // url: "/pages/index/index",
  273. // });
  274. // #endif
  275. // #ifdef H5
  276. uni.showToast({
  277. title: res.data.str,
  278. icon: "none",
  279. });
  280. setTimeout(function() {
  281. uni.navigateTo({
  282. url: '/pages/login/down'
  283. })
  284. }, 1000);
  285. // #endif
  286. // setTimeout(function() {}, 1500);
  287. // console.log("res.data", res.data);
  288. // uni.setStorageSync("wapptoken", res.data.skey);
  289. // getApp().globalData.skey = res.data.skey;
  290. // uni.switchTab({
  291. // url: "/pages/index/home",
  292. // });
  293. } else if (res.data.success == "no") {
  294. uni.showToast({
  295. title: res.data.str,
  296. icon: "none",
  297. });
  298. } else {
  299. uni.showToast({
  300. title: "操作失败,请联系客服",
  301. icon: "none",
  302. });
  303. }
  304. },
  305. complete: (com) => {
  306. uni.hideLoading();
  307. },
  308. });
  309. },
  310. }
  311. }
  312. </script>
  313. <style scoped lang="scss">
  314. @import 'reg.scss';
  315. </style>