reg.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <template>
  2. <view class="content">
  3. <view class="header">
  4. <image :src="staticUrl+'logo.png'"></image>
  5. </view>
  6. <view class="list">
  7. <view class="list-call">
  8. <image class="img" src="/static/shilu-login/1.png"></image>
  9. <input class="sl-input" v-model="phone" type="number" maxlength="11" placeholder="手机号" />
  10. </view>
  11. <view class="list-call">
  12. <image class="img" src="/static/shilu-login/2.png"></image>
  13. <input class="sl-input" v-model="password" type="text" maxlength="32" placeholder="登录密码" :password="!showPassword" />
  14. <image class="img" :src="showPassword?'/static/shilu-login/op.png':'/static/shilu-login/cl.png'" @tap="display"></image>
  15. </view>
  16. <view class="list-call">
  17. <image class="img" src="/static/shilu-login/3.png"></image>
  18. <input class="sl-input" v-model="code" type="number" maxlength="4" placeholder="验证码" />
  19. <view class="yzm" :class="{ yzms: second>0 }" @tap="getcode">{{yanzhengma}}</view>
  20. </view>
  21. <view class="list-call" v-if="iskq==1">
  22. <image class="img" src="/static/shilu-login/4.png"></image>
  23. <input class="sl-input" v-model="invitation" type="text" maxlength="12" placeholder="邀请码 没有留空" />
  24. </view>
  25. </view>
  26. <view class="button-login" hover-class="button-hover" @tap="bindLogin">
  27. <text style="font-size: 40upx;">注册</text>
  28. </view>
  29. <view class="agreement">
  30. <image @tap="agreementSuccess" :src="agreement==true?'/static/shilu-login/ty1.png':'/static/shilu-login/ty0.png'"></image>
  31. <text @tap="agreementSuccess"> 同意</text>
  32. <navigator open-type="navigate">《软件用户协议》</navigator>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. export default {
  38. onLoad(e) {
  39. this.staticUrl=this.configs.staticUrl
  40. if(e.uid){
  41. this.invitation=e.uid
  42. }
  43. this.getList();
  44. },
  45. onUnload() {
  46. clearInterval(js)
  47. this.second = 0;
  48. },
  49. data() {
  50. return {
  51. phone: '',
  52. password: '',
  53. code: '',
  54. invitation: '',
  55. agreement: true,
  56. showPassword: false,
  57. second: 0,
  58. iskq:0,
  59. staticUrl:'',
  60. js:null,
  61. };
  62. },
  63. computed: {
  64. yanzhengma() {
  65. if (this.second == 0) {
  66. return '获取验证码';
  67. } else {
  68. if (this.second < 10) {
  69. return '重新获取0' + this.second;
  70. } else {
  71. return '重新获取' + this.second;
  72. }
  73. }
  74. }
  75. },
  76. onUnload() {
  77. this.clear()
  78. },
  79. methods: {
  80. display() {
  81. this.showPassword = !this.showPassword
  82. },
  83. agreementSuccess() {
  84. this.agreement = !this.agreement;
  85. },
  86. async getcode(){
  87. var _this= this
  88. if (this.phone.length != 11) {
  89. uni.showToast({
  90. icon: 'none',
  91. title: '手机号不正确'
  92. });
  93. return;
  94. }
  95. if(this.second > 0) return;
  96. if(this.second==0){
  97. this.second = 60;
  98. // 请求服务器,发送验证码
  99. //let [err,res] =await this.$httpas.post('/api/ems/index',{'phone':this.phone});
  100. let [err,res] =await this.$httpas.post('/api/sms/send',{'mobile':this.phone,'event':'register'});
  101. if (!this.$httpas.errorCheck(err,res)) return;
  102. if(res.data.ok == 1){
  103. uni.setStorage({//缓存配置信息
  104. key: 'yzmss',
  105. data: res.data.data
  106. })
  107. uni.showToast({ title: res.data.msg,icon:"none" });
  108. }else{
  109. this.second=0
  110. uni.showToast({ title: res.data.msg,icon:"none" });
  111. }
  112. }
  113. _this.js = setInterval(function() {
  114. _this.second--;
  115. if (_this.second <= 0) {
  116. _this.clear()
  117. }
  118. }, 1000)
  119. if(this.second > 0) return;
  120. },
  121. clear(){
  122. clearInterval(this.js)
  123. this.js = null
  124. this.second = 0
  125. },
  126. bindLogin() {
  127. if(this.agreement == false) {
  128. uni.showToast({
  129. icon: 'none',
  130. title: '请先阅读《软件用户协议》'
  131. });
  132. return;
  133. }
  134. if (this.phone.length != 11) {
  135. uni.showToast({
  136. icon: 'none',
  137. title: '手机号不正确'
  138. });
  139. return;
  140. }
  141. if(this.password.length < 6) {
  142. uni.showToast({
  143. icon: 'none',
  144. title: '密码不正确'
  145. });
  146. return;
  147. }
  148. if(!this.code || this.code.length != 4) {
  149. uni.showToast({
  150. icon: 'none',
  151. title: '验证码不正确'
  152. });
  153. return;
  154. }
  155. this.zc();
  156. },
  157. async zc(){
  158. let _this=this;
  159. let data = {'mobile':this.phone,'code':this.code,'username':this.phone,'password':this.password,'pid':this.invitation};
  160. if(this.openid){
  161. data.openid=this.openid
  162. data.nickName=this.nickName
  163. data.avatarUrl=this.avatarUrl
  164. }
  165. let [err,res] =await this.$httpas.post('/api/user/reg',data);
  166. if (!this.$httpas.errorCheck(err,res)) return;
  167. if(res.data.code === 1){
  168. uni.showModal({
  169. title: '',
  170. content: res.data.msg,
  171. showCancel: false,
  172. confirmText: "确定",
  173. success: function (res) {
  174. if (res.confirm) {
  175. uni.navigateBack();
  176. } else if (res.cancel) {
  177. }
  178. }
  179. });
  180. }else{
  181. uni.showToast({ title: res.data.msg,icon:"none" });
  182. }
  183. },
  184. getList() {
  185. let data = {};
  186. var limit=15;
  187. data.limit=limit
  188. data.ishot=2
  189. uni.request({
  190. url: this.configs.webUrl+'/api/video/lists',
  191. data: data,
  192. success: data => {
  193. //console.log(data.data)
  194. uni.setStorage({//缓存配置信息
  195. key: 'config',
  196. data: data.data.config
  197. })
  198. if(uni.getStorageSync("config").iskq){
  199. this.iskq=uni.getStorageSync("config").iskq;
  200. }
  201. },
  202. fail: (data, code) => {
  203. }
  204. });
  205. },
  206. }
  207. }
  208. </script>
  209. <style>
  210. .content {
  211. display: flex;
  212. flex-direction: column;
  213. justify-content: center;
  214. }
  215. .header {
  216. width: 161rpx;
  217. height: 161rpx;
  218. background: rgba(63, 205, 235, 1);
  219. box-shadow: 0rpx 12rpx 13rpx 0rpx rgba(63, 205, 235, 0.47);
  220. border-radius: 50%;
  221. margin-top: 30rpx;
  222. margin-left: auto;
  223. margin-right: auto;
  224. }
  225. .header image {
  226. width: 161rpx;
  227. height: 161rpx;
  228. border-radius: 50%;
  229. }
  230. .list {
  231. display: flex;
  232. flex-direction: column;
  233. padding-top: 50rpx;
  234. padding-left: 70rpx;
  235. padding-right: 70rpx;
  236. }
  237. .list-call {
  238. display: flex;
  239. flex-direction: row;
  240. justify-content: space-between;
  241. align-items: center;
  242. height: 100rpx;
  243. color: #333333;
  244. border-bottom: 0.5px solid #e2e2e2;
  245. }
  246. .list-call .img {
  247. width: 40rpx;
  248. height: 40rpx;
  249. }
  250. .list-call .sl-input {
  251. flex: 1;
  252. text-align: left;
  253. font-size: 32rpx;
  254. margin-left: 16rpx;
  255. }
  256. .yzm {
  257. color: #FF7D13;
  258. font-size: 24rpx;
  259. line-height: 64rpx;
  260. padding-left: 10rpx;
  261. padding-right: 10rpx;
  262. width: auto;
  263. height: 64rpx;
  264. border: 1rpx solid #FFA800;
  265. border-radius: 50rpx;
  266. }
  267. .yzms {
  268. color: #999999 !important;
  269. border: 1rpx solid #999999;
  270. }
  271. .button-login {
  272. color: #FFFFFF;
  273. font-size: 34rpx;
  274. width: 470rpx;
  275. height: 100rpx;
  276. line-height: 100rpx;
  277. background: linear-gradient(-90deg, rgba(75, 196, 93, 1), rgba(188, 226, 158, 1));
  278. box-shadow: 0rpx 0rpx 13rpx 0rpx rgba(164, 217, 228, 0.2);
  279. border-radius: 50rpx;
  280. text-align: center;
  281. margin-left: auto;
  282. margin-right: auto;
  283. margin-top: 100rpx;
  284. }
  285. .button-hover {
  286. background: linear-gradient(-90deg, rgba(75, 196, 93, 1), rgba(188, 226, 158, 1));
  287. }
  288. .agreement {
  289. display: flex;
  290. flex-direction: row;
  291. justify-content: center;
  292. align-items: center;
  293. font-size: 30rpx;
  294. margin-top: 80rpx;
  295. color: #FFA800;
  296. text-align: center;
  297. height: 40rpx;
  298. line-height: 40rpx;
  299. }
  300. .agreement image {
  301. width: 40rpx;
  302. height: 40rpx;
  303. }
  304. </style>