index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <view>
  3. <view class="status_bar">
  4. <!-- 这里是状态栏 -->
  5. </view>
  6. <u-image src="../../static/sailun/login_bg.png" mode="widthFix"></u-image>
  7. <view class="content">
  8. <u-card padding="50" :head-border-bottom="false" :show-head="false" :show-foot="false" :border="false" box-shadow="0px 1px 10px rgba(0,0,0,0.2)"
  9. border-radius="20" margin="50rpx">
  10. <view slot="body">
  11. <view style="margin-top: 20rpx;">
  12. <u-field v-model="tel" placeholder="请填写手机号" label-width="50">
  13. <u-icon slot="icon" name="account" size="36" color="#666666"></u-icon>
  14. </u-field>
  15. </view>
  16. <view style="margin-top: 30rpx;">
  17. <u-field v-model="code" placeholder="请填写验证码" label-width="50">
  18. <u-icon slot="icon" name="lock" size="36" color="#666666"></u-icon>
  19. <u-button size="mini" slot="right" type="primary" @click="getCode" shape="circle" :loading="codeLoading">{{codeText}}</u-button>
  20. </u-field>
  21. </view>
  22. <u-verification-code ref="uCode" @change="codeChange"></u-verification-code>
  23. <view style="margin-top: 80rpx;">
  24. <u-button type="primary" :ripple="true" ripple-bg-color="#99d4ff" shape="circle" @tap="$u.debounce(submit, 2000,immediate = true)"
  25. :loading="loading">登录</u-button>
  26. </view>
  27. <view style="margin-top: 80rpx;display: flex;justify-content: center;">
  28. <view class="u-flex" @click="inregister">
  29. <view style="color: rgba(0,160,234,0.5)">
  30. 还没有账号?
  31. </view>
  32. <view style="color: #00A0EA">
  33. 立即注册
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </u-card>
  39. </view>
  40. <view class="foot">
  41. <view class="u-flex u-row-center u-col-center">
  42. <u-divider color="#0095FF" border-color="#0095FF" bg-color="#F4F4F4" fontSize="30">赛轮店管家</u-divider>
  43. </view>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. import permision from "@/js_sdk/wa-permission/permission.js"
  49. import {
  50. mapState,
  51. mapMutations
  52. } from 'vuex'
  53. import {
  54. request
  55. } from '../../common/request/request'
  56. require("promise.prototype.finally").shim()
  57. export default {
  58. data() {
  59. return {
  60. tel: '',
  61. code: '',
  62. codeText: '',
  63. pact: false,
  64. loading: false,
  65. codeLoading: false,
  66. SystemInfo: '',
  67. networkType: ''
  68. }
  69. },
  70. computed: {
  71. ...mapState(['hasLogin'])
  72. },
  73. created() {
  74. uni.getSystemInfo({
  75. success: (res) => {
  76. this.SystemInfo = res
  77. }
  78. });
  79. uni.getNetworkType({
  80. success: (res) => {
  81. this.networkType = res.networkType
  82. }
  83. });
  84. if(this.SystemInfo.platform=="ios"){
  85. this.judgeIosPermission()
  86. }else{
  87. this.requestAndroidPermission()
  88. }
  89. },
  90. methods: {
  91. ...mapMutations(['login']),
  92. judgeIosPermission() {
  93. let result = permision.judgeIosPermission('location')
  94. if (!result) {
  95. uni.showModal({
  96. title: "温馨提示",
  97. content: "为了更好地服务,请开启定位权限,是否同意?",
  98. cancelText: "不同意",
  99. confirmText: "同意",
  100. success: res => {
  101. if (res.confirm) {
  102. plus.runtime.openURL("app-settings://");
  103. }
  104. }
  105. })
  106. }
  107. },
  108. async requestAndroidPermission() {
  109. let result = await permision.requestAndroidPermission('android.permission.ACCESS_FINE_LOCATION')
  110. },
  111. toUser(provider) {
  112. this.login(provider);
  113. if (this.hasLogin) {
  114. this.$u.route({
  115. url: 'pages/home/index',
  116. type: 'switchTab',
  117. })
  118. } else {
  119. uni.navigateBack();
  120. }
  121. },
  122. submit() {
  123. if (this.$u.test.mobile(this.tel)) {
  124. this.loading = true
  125. request({
  126. url: '/sailun/appLogin/storeLogin',
  127. method: 'post',
  128. data: {
  129. "account": "",
  130. "loginType": "1",
  131. "mobileCode": this.code,
  132. "password": "",
  133. "phoneNumber": this.tel,
  134. "osType": this.SystemInfo.platform,
  135. "osVersion": this.SystemInfo.system,
  136. "phoneBrand": this.SystemInfo.brand,
  137. "phoneModel": this.SystemInfo.model,
  138. "appVersion": "1.00",
  139. "networkType": this.networkType,
  140. }
  141. }).then(res => {
  142. if (res.data.code == 0) {
  143. this.toUser(res.data.data)
  144. uni.$emit('login', {
  145. msg: '登录成功'
  146. })
  147. } else {
  148. this.$u.toast(res.data.msg);
  149. }
  150. }).catch(err => {
  151. console.log(err)
  152. this.$u.toast('登录失败');
  153. }).finally(() => {
  154. this.loading = false
  155. })
  156. }
  157. },
  158. inregister() {
  159. this.$u.route({
  160. url: 'pages/login/register',
  161. })
  162. },
  163. codeChange(text) {
  164. this.codeText = text;
  165. },
  166. getCode() {
  167. if (this.tel) {
  168. this.codeLoading = true
  169. request({
  170. url: '/sailun/appStoreBasicInfo/sendCode',
  171. method: 'post',
  172. data: {
  173. "phoneNumber": this.tel,
  174. "opreaType": "1"
  175. },
  176. }).then(res => {
  177. console.log(res)
  178. if (res.data.code == 0) {
  179. if (this.$refs.uCode.canGetCode) {
  180. this.$refs.uCode.start();
  181. } else {
  182. this.$u.toast('倒计时结束后再发送');
  183. }
  184. }
  185. if (res.data.code == 500) {
  186. this.$u.toast(res.data.msg);
  187. }
  188. }).catch(err => {
  189. console.log(err)
  190. }).finally(() => {
  191. this.codeLoading = false
  192. })
  193. } else {
  194. this.$u.toast('请输入手机号');
  195. }
  196. },
  197. }
  198. };
  199. </script>
  200. <style lang="scss" scoped>
  201. .status_bar {
  202. height: var(--status-bar-height);
  203. width: 100%;
  204. background-color: #0095FF;
  205. }
  206. .content {
  207. position: relative;
  208. top: -350rpx;
  209. }
  210. .foot {
  211. position: fixed;
  212. bottom: 10rpx;
  213. width: 100%;
  214. }
  215. </style>