login.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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. <block v-if="type == 'onelogin'">
  10. <image class="icon" mode="widthFix" src="../../static/me/avator.png"></image>
  11. <text class="mobile">+ 86 177****9870</text>
  12. <text class="tips">首次验证通过即注册遇见玛特账号</text>
  13. <text class="btn_submit">本机号码一键登录</text>
  14. <view class="other">
  15. <view class="pass" @click="type = 'pass'">密码登录</view>
  16. <view class="line"></view>
  17. <view class="mob" @click="type = 'mobile'">手机号登录</view>
  18. </view>
  19. </block>
  20. <block v-if="type == 'mobile' || type == 'pass'">
  21. <view class="name">手机号码:</view>
  22. <view class="item">
  23. <input type="text" class="input" v-model="mobile" placeholder="请输入手机号码" maxlength="11"/>
  24. </view>
  25. <block v-if="type == 'pass'">
  26. <view class="name">登录密码:</view>
  27. <view class="item">
  28. <input type="password" class="input" v-model="password" placeholder="请输入登录密码" maxlength="32"/>
  29. </view>
  30. <view class="other_list">
  31. <text class="left" v-if="false">忘记密码</text>
  32. <text class="left" v-else></text>
  33. <text class="right" @click="type = 'mobile'" v-if="false">验证码登录</text>
  34. <text class="right" @click="toRegist">还没有账号?开始注册</text>
  35. </view>
  36. </block>
  37. <block v-if="type == 'mobile'">
  38. <view class="name">验证码:</view>
  39. <view class="item">
  40. <input type="text" class="input" v-model="code" placeholder="请输入验证码" maxlength="6"/>
  41. <view class="btn">获取验证码</view>
  42. </view>
  43. <view class="other_list">
  44. <text class="left"></text>
  45. <text class="right" @click="type = 'pass'">密码登录</text>
  46. </view>
  47. </block>
  48. <text class="btn_submit" @click="toLogin">登录</text>
  49. </block>
  50. <view class="wechat" v-if="false">
  51. <image class="img" mode="widthFix" src="../../static/login/wechat.png"></image>
  52. </view>
  53. <view class="agree">
  54. <view class="agree2" @click="agreeChk()">
  55. <image mode="widthFix" src="../../static/login/sel_no.png" v-if="is_agree == 0"></image>
  56. <image mode="widthFix" src="../../static/login/sel_yes.png" v-if="is_agree == 1"></image>
  57. <text>我已阅读并同意</text>
  58. </view>
  59. <text class="xy" @click="goPage('yhxy')">
  60. 隐私协议
  61. </text>
  62. 》和《
  63. <text class="xy" @click="goPage('yszc')">
  64. 用户使用协议
  65. </text>
  66. </view>
  67. </view>
  68. <view class="blankHeight"></view>
  69. <!-- 提示框 -->
  70. <DialogBox ref="DialogBox"></DialogBox>
  71. </view>
  72. </template>
  73. <script>
  74. export default {
  75. components: {},
  76. data() {
  77. return {
  78. title: '',
  79. sel: 1,
  80. is_agree: 0,
  81. type: 'pass',
  82. myinfo: {
  83. nickname: '王思思',
  84. join_name: '注册日期:2024年5月',
  85. num_1: 0,
  86. num_2: 0,
  87. num_3: 0,
  88. num_4: 0,
  89. is_login: 'no',
  90. num_history: 0,
  91. num_collection: 0
  92. },
  93. mobile: '',
  94. password: '',
  95. code: '',
  96. }
  97. },
  98. onLoad() {
  99. setTimeout(function() {
  100. uni.setNavigationBarColor({
  101. frontColor: '#ffffff',
  102. backgroundColor: '#00000000',
  103. animation: {
  104. duration: 400,
  105. timingFunc: 'easeIn'
  106. }
  107. })
  108. }, 200);
  109. },
  110. onShow() {
  111. if (getApp().globalData.skey != "") {
  112. // console.log("====", getApp().globalData.skey);
  113. uni.switchTab({
  114. url: "/pages/index/index"
  115. });
  116. }
  117. // this.loadData();
  118. },
  119. methods: {
  120. onBack() {},
  121. agreeChk() {
  122. if (this.is_agree == 0) {
  123. this.is_agree = 1;
  124. } else {
  125. this.is_agree = 0;
  126. }
  127. },
  128. goPage(page) {
  129. if (page == 'yhxy') {
  130. uni.navigateTo({
  131. url: '/pages/AboutUs/yhxy'
  132. })
  133. } else if (page == 'yszc') {
  134. uni.navigateTo({
  135. url: '/pages/AboutUs/yszc'
  136. })
  137. } else {
  138. uni.navigateTo({
  139. url: page,
  140. });
  141. }
  142. },
  143. toRegist() {
  144. uni.navigateTo({
  145. url: "/pages/login/reg",
  146. });
  147. },
  148. toLogin() {
  149. if (this.mobile.length != 11) {
  150. uni.showToast({
  151. title: "请输入手机号",
  152. icon: "none",
  153. });
  154. return;
  155. }
  156. if (this.type == 'pass') {
  157. if (this.password.length < 6) {
  158. uni.showToast({
  159. title: "请输入不小于6位的密码",
  160. icon: "none",
  161. });
  162. return;
  163. }
  164. } else {
  165. if (this.code.length < 4) {
  166. uni.showToast({
  167. title: "请输入手机验证码",
  168. icon: "none",
  169. });
  170. return;
  171. }
  172. }
  173. if (this.is_agree == 0) {
  174. uni.showToast({
  175. title: "请确认并选择协议",
  176. icon: "none",
  177. });
  178. return;
  179. }
  180. let method = '/Member/gamelogin';
  181. if (this.btn_type == 'reg') {
  182. method = '/Member/register';
  183. if (this.code.length < 4) {
  184. uni.showToast({
  185. title: '请输入验证码',
  186. icon: 'none'
  187. });
  188. return;
  189. }
  190. } else if (this.btn_type == 'reset') {
  191. method = '/Member/resetPass';
  192. if (this.code.length < 4) {
  193. uni.showToast({
  194. title: '请输入验证码',
  195. icon: 'none'
  196. });
  197. return;
  198. }
  199. }
  200. uni.showLoading({
  201. mask: true,
  202. });
  203. console.log("host", this.$apiHost + method);
  204. uni.request({
  205. url: this.$apiHost + method, //仅为示例,并非真实接口地址。
  206. data: {
  207. uuid: getApp().globalData.uuid,
  208. loginType: this.type,
  209. mobile: this.mobile,
  210. password: this.password,
  211. code: this.code
  212. },
  213. header: {
  214. "content-type": "application/json", //自定义请求头信息
  215. },
  216. success: (res) => {
  217. console.log("----", res.data);
  218. if (res.data.success == "yes") {
  219. console.log("res.data", res.data);
  220. uni.setStorageSync("wapptoken", res.data.skey);
  221. getApp().globalData.skey = res.data.skey;
  222. if (res.data.nickname == '') {
  223. uni.redirectTo({
  224. url: '/pages/login/loginFirst'
  225. });
  226. return;
  227. }
  228. uni.switchTab({
  229. url: "/pages/index/index",
  230. });
  231. } else if (res.data.success == "no") {
  232. uni.showToast({
  233. title: res.data.str,
  234. icon: "none",
  235. });
  236. } else {
  237. uni.showToast({
  238. title: "操作失败,请联系客服",
  239. icon: "none",
  240. });
  241. }
  242. },
  243. complete: (com) => {
  244. uni.hideLoading();
  245. },
  246. });
  247. },
  248. }
  249. }
  250. </script>
  251. <style scoped lang="scss">
  252. @import 'login.scss';
  253. </style>