index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. <template>
  2. <view v-if="config" style="overflow: hidden;margin-bottom: 20rpx;min-height: 100vh;position: relative;">
  3. <!-- 背景图 -->
  4. <image class="wdbg" src="../../static/bg.png" mode="widthFix"></image>
  5. <!-- 表单 -->
  6. <view class="form-bar">
  7. <view class="logo-box">
  8. <view class="logo-image"><image :src="config.CONFIG_PROJECT_LOGO"></image></view>
  9. <view class="logo-text">{{ config.CONFIG_PROJECT_TITLE }}</view>
  10. </view>
  11. <view v-if="mobileRegister" class="form-box">
  12. <view class="form-item">
  13. <view class="or-text or-text-b">
  14. <view>
  15. <text>您已使用</text>
  16. {{ mobileRegister }}
  17. <text>完成注册</text>
  18. </view>
  19. </view>
  20. </view>
  21. <!-- 按钮 -->
  22. <view class="submit-btn" @click="downloadApp()">下载APP</view>
  23. </view>
  24. <view v-else class="form-box">
  25. <view class="form-item">
  26. <text class="number86">+86</text>
  27. <input placeholder="请输入手机号" v-model="mobile" type="number" maxlength="11" placeholder-class="placeholder" class="ipt" />
  28. </view>
  29. <view class="form-item">
  30. <input v-model="code" type="number" maxlength="6" placeholder="请输验证码" placeholder-class="placeholder" class="ipt" />
  31. <view class="code-btn gary-text" @click="getCode()" v-text="sendMsg"></view>
  32. </view>
  33. <view class="form-item noborder" v-if="userInfo">
  34. <image class="form-icon" src="../../static/member.png"></image>
  35. <text class="gary-text">
  36. 邀请人
  37. <span style="color: #333;margin-left: 10rpx;">{{ userInfo.nickName }}</span>
  38. </text>
  39. </view>
  40. <!-- 按钮 -->
  41. <view class="submit-btn" @click="submitRegister()">注册并下载APP</view>
  42. </view>
  43. </view>
  44. <view class="gary-text footer-bar">
  45. <view>
  46. <text style="margin-right: 10rpx;" @click="jump('/pages/userAgreement/index?appId=' + appId)">服务协议</text>
  47. <text style="margin-left: 10rpx;" @click="jump('/pages/privacyAgreement/index?appId=' + appId)">隐私政策</text>
  48. </view>
  49. <view>{{ config.CONFIG_RECORD_NUMBER }}</view>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. const req = require('../../utils/request.js');
  55. const util = require('../../utils/util.js');
  56. export default {
  57. data() {
  58. return {
  59. appId: '',
  60. userId: '', //推荐人用户Id;
  61. config: '',
  62. mobile: '', //手机号
  63. code: '', //code
  64. sendMsg: '获取验证码',
  65. isGetCodeDisabled: false,
  66. mobileRegister: '', //用户注册缓存的手机号
  67. userInfo: '', //被邀请人对象
  68. pickleChannel: '', //投放渠道
  69. packageChannel: '' //包的渠道
  70. };
  71. },
  72. onLoad(opt) {
  73. this.mobileRegister = req.getStorage('mobileRegister');
  74. this.appId = opt.appId;
  75. // this.appId = 'ZQWYx7XoOOhv4Ns';
  76. this.userId = opt.userId;
  77. this.pickleChannel = opt.pickleChannel;
  78. this.packageChannel = opt.packageChannel;
  79. req.setStorage('pickleChannel', this.pickleChannel);
  80. req.setStorage('packageChannel', this.packageChannel);
  81. this.getConfig();
  82. if (this.userId) {
  83. this.getUeserInfo();
  84. }
  85. },
  86. methods: {
  87. getConfig() {
  88. req.getRequest(
  89. '/api/config',
  90. this.appId,
  91. {},
  92. data => {
  93. req.setStorage('config', data);
  94. this.config = data;
  95. },
  96. true
  97. );
  98. },
  99. jump(url) {
  100. uni.navigateTo({
  101. url: url
  102. });
  103. },
  104. getUeserInfo() {
  105. req.getRequest(
  106. '/api/user/getInfo',
  107. this.appId,
  108. { userId: this.userId },
  109. data => {
  110. this.userInfo = data;
  111. },
  112. true
  113. );
  114. },
  115. getCode() {
  116. if (this.isGetCodeDisabled == true) return false;
  117. if (!this.mobile) {
  118. req.msg('请输入手机号');
  119. return;
  120. }
  121. if (!util.isMobile(this.mobile)) {
  122. req.msg('请输入11位有效手机号');
  123. return;
  124. }
  125. req.postRequest(
  126. '/api/sms/login',
  127. this.appId,
  128. {
  129. mobile: this.mobile
  130. },
  131. data => {
  132. req.msg('验证码获取成功');
  133. let time = 60;
  134. let interval = setInterval(() => {
  135. time--;
  136. if (time == 0) {
  137. this.isGetCodeDisabled = false;
  138. this.sendMsg = '获取验证码';
  139. clearInterval(interval);
  140. } else {
  141. this.isGetCodeDisabled = true;
  142. this.sendMsg = time + '秒后再获取';
  143. }
  144. }, 1000);
  145. },
  146. true
  147. );
  148. },
  149. submitRegister() {
  150. if (!this.mobile) {
  151. req.msg('请输入手机号');
  152. return;
  153. }
  154. if (!this.code) {
  155. req.msg('请输入验证码');
  156. return;
  157. }
  158. var dataP = {
  159. mobile: this.mobile,
  160. code: this.code,
  161. parentId: this.userId
  162. };
  163. req.postRequest(
  164. '/api/mobileLogin',
  165. this.appId,
  166. dataP,
  167. data => {
  168. if (data.isNewRegister) {
  169. req.setStorage('mobileRegister', util.phoneHintText(this.mobile));
  170. this.downloadApp();
  171. } else {
  172. req.msg('当前手机号已经注册过了');
  173. }
  174. },
  175. true
  176. );
  177. },
  178. /**
  179. * 下载app
  180. */
  181. downloadApp() {
  182. this.jump('/pages/downloadApp/index?appId=' + this.appId);
  183. },
  184. // // 去下载
  185. // downloadApp() {
  186. // var u = navigator.userAgent;
  187. // var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1;
  188. // var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
  189. // // 这里是iOS浏览器
  190. // if (isIOS) {
  191. // if (this.config.download_app_ios_url) {
  192. // window.location.href = this.config.download_app_ios_url; // 跳AppStore下载地址
  193. // } else {
  194. // this.showModal('后台暂未开放IOS App版本下载');
  195. // }
  196. // } else {
  197. // // 是微信内部webView
  198. // // if (is_weixn()) {
  199. // // this.showModal('请点击右上角“...”按钮, 选择在浏览器打开');
  200. // // } else {
  201. // if (this.config.download_app_android_url) {
  202. // window.location.href = this.config.download_app_android_url; // 跳AppStore下载地址
  203. // } else {
  204. // this.showModal('后台暂未开放Android App版本下载');
  205. // }
  206. // // }
  207. // }
  208. // },
  209. // // 是微信浏览器
  210. // is_weixn() {
  211. // var ua = navigator.userAgent.toLowerCase();
  212. // if (ua.match(/MicroMessenger/i) == 'micromessenger') {
  213. // return true;
  214. // } else {
  215. // return false;
  216. // }
  217. // },
  218. // IsPC() {
  219. // var userAgentInfo = navigator.userAgent;
  220. // var Agents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPad', 'iPod'];
  221. // var flag = true;
  222. // for (var v = 0; v < Agents.length; v++) {
  223. // if (userAgentInfo.indexOf(Agents[v]) > 0) {
  224. // flag = false;
  225. // break;
  226. // }
  227. // }
  228. // return flag;
  229. // },
  230. showModal(msg) {
  231. uni.showModal({
  232. title: '提示',
  233. content: msg,
  234. confirmText: '关闭',
  235. showCancel: false,
  236. success(res) {}
  237. });
  238. }
  239. }
  240. };
  241. </script>
  242. <style>
  243. page {
  244. background: transparent;
  245. }
  246. .wdbg {
  247. display: block;
  248. width: 100%;
  249. height: auto;
  250. position: absolute;
  251. top: 0;
  252. left: 0;
  253. z-index: -1;
  254. }
  255. .logo-box {
  256. padding-top: 40rpx;
  257. }
  258. .logo-image {
  259. width: 100rpx;
  260. height: 100rpx;
  261. margin: auto;
  262. }
  263. .logo-text {
  264. text-align: center;
  265. margin-top: 10rpx;
  266. }
  267. .logo-image image {
  268. width: 100%;
  269. height: 100%;
  270. }
  271. .form-bar {
  272. background-color: #fff;
  273. border-radius: 50rpx;
  274. margin: 600rpx 50rpx 50rpx 50rpx;
  275. z-index: 2;
  276. }
  277. .form-bar::before {
  278. content: '';
  279. display: block;
  280. clear: both;
  281. }
  282. .form-ba::after {
  283. content: '';
  284. display: block;
  285. clear: both;
  286. }
  287. .form-box {
  288. padding: 30rpx 40rpx 100rpx 40rpx;
  289. }
  290. .form-box .form-item {
  291. display: flex;
  292. padding: 20rpx 10rpx;
  293. border-bottom: 1rpx solid #ebebeb;
  294. align-items: center;
  295. }
  296. .form-box .form-item:last-of-type {
  297. border-bottom: none;
  298. }
  299. .form-box .form-item input {
  300. flex: 1;
  301. }
  302. .form-box .form-item .form-icon {
  303. width: 30rpx;
  304. height: 30rpx;
  305. margin-right: 10rpx;
  306. }
  307. .placeholder {
  308. color: #999;
  309. }
  310. .ipt {
  311. font-size: 30rpx;
  312. color: #333;
  313. height: 70rpx;
  314. line-height: 70rpx;
  315. }
  316. .number86 {
  317. font-size: 30rpx;
  318. padding-right: 20rpx;
  319. margin-right: 20rpx;
  320. border-right: 1rpx solid #ebebeb;
  321. }
  322. .code-btn {
  323. padding: 10rpx 20rpx;
  324. border-radius: 10rpx;
  325. border: 2rpx solid #999;
  326. }
  327. .or-text {
  328. color: #ff7116;
  329. font-size: 30rpx;
  330. padding-left: 10rpx;
  331. padding-right: 10rpx;
  332. }
  333. .or-text-b {
  334. margin: 20rpx auto;
  335. text-align: center;
  336. }
  337. .or-text-b text {
  338. color: #333;
  339. }
  340. .gary-text {
  341. color: #999;
  342. font-size: 24rpx;
  343. }
  344. .noborder {
  345. border: none !important;
  346. }
  347. .submit-btn {
  348. background-color: #ff7116;
  349. color: #fff;
  350. border-radius: 50rpx;
  351. padding: 20rpx 50rpx;
  352. text-align: center;
  353. font-weight: bold;
  354. margin-top: 50rpx;
  355. }
  356. .footer-bar {
  357. /* margin: 50rpx auto; */
  358. position: absolute;
  359. bottom: 20rpx;
  360. width: 100%;
  361. text-align: center;
  362. }
  363. .footer-bar text {
  364. color: #333;
  365. text-decoration: underline;
  366. }
  367. .footer-bar view {
  368. margin: 10rpx auto;
  369. }
  370. </style>