index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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="$t('login.mobile')" 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="$t('login.code')" label-width="50" maxlength="6">
  18. <u-icon slot="icon" name="lock" size="36" color="#666666"></u-icon>
  19. <u-button v-if="send!='zh'" size="mini" slot="right" type="primary" @click="getCode" shape="circle" :loading="codeLoading">{{codeText}}</u-button>
  20. <u-button v-else size="mini" slot="right" type="primary" @click="getCode" shape="circle" :loading="codeLoading">{{codeText}}</u-button>
  21. </u-field>
  22. </view>
  23. <view class="" v-if="send!='zh'">
  24. <u-verification-code ref="uCode" @change="codeChange"></u-verification-code>
  25. </view>
  26. <u-verification-code v-else ref="uCode" @change="codeChange" start-text="Send" change-text="Reacquire in X S" end-text="Reacquire"></u-verification-code>
  27. <view style="margin-top: 80rpx;">
  28. <u-button type="primary" :ripple="true" ripple-bg-color="#99d4ff" shape="circle" @tap="$u.debounce(submit, 2000,immediate = true)"
  29. :loading="loading">{{$t("login.login")}}</u-button>
  30. </view>
  31. <view style="margin-top: 80rpx;display: flex;justify-content: center;">
  32. <view class="u-flex" @click="inregister">
  33. <view style="color: rgba(0,160,234,0.5)">
  34. {{$t("login.no")}}
  35. </view>
  36. <view style="color: #00A0EA">
  37. {{$t("login.sign")}}
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </u-card>
  43. </view>
  44. <view class="foot">
  45. <view class="u-flex u-row-center u-col-center">
  46. <!-- <u-divider color="#0095FF" border-color="#0095FF" bg-color="#F4F4F4" fontSize="30" @click="switchLang">{{$t("login.Lan")}}</u-divider> -->
  47. <u-divider color="#0095FF" border-color="#0095FF" bg-color="#F4F4F4" fontSize="30">赛轮集团</u-divider>
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. import permision from "@/js_sdk/wa-permission/permission.js"
  54. import {
  55. mapState,
  56. mapMutations
  57. } from 'vuex'
  58. import {
  59. request
  60. } from '../../common/request/request'
  61. require("promise.prototype.finally").shim()
  62. export default {
  63. data() {
  64. return {
  65. tel: '',
  66. code: '',
  67. codeText:"",
  68. pact: false,
  69. loading: false,
  70. codeLoading: false,
  71. SystemInfo: '',
  72. networkType: '',
  73. version: '',
  74. send:'',
  75. }
  76. },
  77. computed: {
  78. ...mapState(['hasLogin'])
  79. },
  80. created() {
  81. uni.getSystemInfo({
  82. success: (res) => {
  83. this.SystemInfo = res
  84. }
  85. });
  86. uni.getNetworkType({
  87. success: (res) => {
  88. this.networkType = res.networkType
  89. }
  90. });
  91. // #ifdef APP-PLUS
  92. uni.getLocation({
  93. success: res => {},
  94. fail: err => {
  95. if (this.SystemInfo.platform == "ios") {
  96. this.judgeIosPermission()
  97. } else {
  98. this.requestAndroidPermission()
  99. }
  100. }
  101. });
  102. // #endif
  103. // #ifdef APP-PLUS
  104. plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
  105. this.version = wgtinfo.version
  106. })
  107. // #endif
  108. uni.$on('loginphone', data => {
  109. this.tel = data
  110. })
  111. },
  112. methods: {
  113. switchLang() {
  114. this.$i18n.locale = this.$i18n.locale == 'en' ? 'zh' : 'en';
  115. this.send= this.$i18n.locale == 'en' ? 'zh' : 'en';
  116. },
  117. ...mapMutations(['login']),
  118. judgeIosPermission() {
  119. let result = permision.judgeIosPermission('location')
  120. if (!result) {
  121. uni.showModal({
  122. title: this.$t('login.locationtitle'),
  123. content:this.$t('login.locationcontent'),
  124. cancelText:this.$t('login.locationcancelText'),
  125. confirmText: this.$t('login.locationconfirmText'),
  126. success: res => {
  127. if (res.confirm) {
  128. plus.runtime.openURL("app-settings://");
  129. }
  130. }
  131. })
  132. }
  133. },
  134. async requestAndroidPermission() {
  135. let result = await permision.requestAndroidPermission('android.permission.ACCESS_FINE_LOCATION')
  136. },
  137. toUser(provider) {
  138. this.login(provider);
  139. if (this.hasLogin) {
  140. this.$u.route({
  141. url: 'pages/home/index',
  142. type: 'switchTab',
  143. })
  144. } else {
  145. uni.navigateBack();
  146. }
  147. },
  148. submit() {
  149. if (this.$u.test.mobile(this.tel)) {
  150. this.loading = true
  151. request({
  152. url: '/sailun/appLogin/storeLogin',
  153. method: 'post',
  154. data: {
  155. "account": "",
  156. "loginType": "1",
  157. "mobileCode": this.code,
  158. "password": "",
  159. "phoneNumber": this.tel,
  160. "osType": this.SystemInfo.platform,
  161. "osVersion": this.SystemInfo.system,
  162. "phoneBrand": this.SystemInfo.brand,
  163. "phoneModel": this.SystemInfo.model,
  164. "appVersion": this.version,
  165. "networkType": this.networkType,
  166. }
  167. }).then(res => {
  168. if (res.data.code == 0) {
  169. this.toUser(res.data.data)
  170. uni.$emit('login', {
  171. msg: this.$t('login.suclogin')
  172. })
  173. } else {
  174. this.$u.toast(res.data.msg);
  175. }
  176. }).catch(err => {
  177. this.$u.toast(this.$t('login.errlogin'));
  178. }).finally(() => {
  179. this.loading = false
  180. })
  181. }
  182. },
  183. inregister() {
  184. this.$u.route({
  185. url: 'pages/login/register',
  186. })
  187. },
  188. codeChange(text) {
  189. this.codeText = text;
  190. },
  191. getCode() {
  192. if (this.$u.test.mobile(this.tel)) {
  193. if (this.$refs.uCode.canGetCode) {
  194. this.codeLoading = true
  195. request({
  196. url: '/sailun/appStoreBasicInfo/sendCode',
  197. method: 'post',
  198. data: {
  199. "phoneNumber": this.tel,
  200. "opreaType": "1"
  201. },
  202. }).then(res => {
  203. if (res.data.code == 0) {
  204. this.$refs.uCode.start();
  205. }
  206. if (res.data.code == 500) {
  207. this.$u.toast(res.data.msg);
  208. }
  209. }).catch(err => {
  210. }).finally(() => {
  211. this.codeLoading = false
  212. })
  213. } else {
  214. this.$u.toast(this.$t('login.repeatcode'));
  215. }
  216. } else {
  217. this.$u.toast(this.$t('login.telcode'));
  218. }
  219. },
  220. }
  221. };
  222. </script>
  223. <style lang="scss" scoped>
  224. .status_bar {
  225. height: var(--status-bar-height);
  226. width: 100%;
  227. background-color: #0095FF;
  228. }
  229. .content {
  230. position: relative;
  231. top: -400rpx;
  232. }
  233. .foot {
  234. position: fixed;
  235. bottom: 10rpx;
  236. width: 100%;
  237. padding-bottom: 0;
  238. padding-bottom: constant(safe-area-inset-bottom);
  239. padding-bottom: env(safe-area-inset-bottom);
  240. }
  241. </style>