login.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <view>
  3. <view class="login-view">
  4. <image :src="logo" class="logo" mode="widthFix"></image>
  5. <view class="t-login">
  6. <u-button type="primary" class="custom-style" shape="circle" open-type="getPhoneNumber"
  7. @getphonenumber="getPhoneNumber" color="linear-gradient(0deg, #FD5003 0%, #FBA680 100%)"
  8. :ripple="true">
  9. 授权手机号登录
  10. </u-button>
  11. </view>
  12. </view>
  13. <div style="margin-top: 20rpx;display: flex;justify-content: center;">
  14. <view>
  15. <u-checkbox-group v-model="checkboxValue1" placement="column">
  16. <u-checkbox :customStyle="{marginBottom: '8px'}"></u-checkbox>
  17. </u-checkbox-group>
  18. </view>
  19. <view>
  20. <text>我已阅读</text>
  21. <text style="color: #73a8fc;" @click="tiaozhuanxieyi">《 用户协议 》</text>
  22. </view>
  23. </div>
  24. <view style="position:absolute; bottom:20rpx;font-size: 20rpx;width: 100%;text-align: center;z-index: -1;">
  25. <image src="/static/images/login/bottom.png" style="
  26. display: block;
  27. width: 60%;
  28. height: auto;
  29. margin: 0 auto 10rpx;" mode="widthFix"></image>
  30. 青岛途宝软件开发有限公司提供技术支持
  31. </view>
  32. <PrivacyPop ref="PrivacyPopck"></PrivacyPop>
  33. </view>
  34. </template>
  35. <script>
  36. import {
  37. isProcurement
  38. } from '@/api/tabBar/homeNew.js'
  39. import PrivacyPop from './PrivacyPop/PrivacyPop.vue'
  40. import md5 from '@/utils/md5.js'
  41. export default {
  42. components: {
  43. PrivacyPop
  44. },
  45. data() {
  46. return {
  47. phone: '', //手机号码
  48. pwd: '', //密码
  49. // phone: '13021669111', //手机号码18669858069
  50. // pwd: '123456', //密码
  51. checked: false,
  52. lifeData: {},
  53. logo: "/static/images/logo/logo.png",
  54. checkboxValue1: [],
  55. }
  56. },
  57. onLoad(options) {
  58. if (options) {
  59. uni.setStorageSync('QRcodeDate', options);
  60. }
  61. },
  62. onShow() {
  63. },
  64. methods: {
  65. // 协议跳转
  66. tiaozhuanxieyi() {
  67. uni.$u.route('pages/login/xieyi')
  68. },
  69. zhuangtao(type) {
  70. this.checkboxValue1 = [""]
  71. },
  72. change(e) {
  73. this.checked = !this.checked
  74. },
  75. //当前登录按钮操作
  76. getPhoneNumber(e) {
  77. console.log(e, 73);
  78. let this_ = this
  79. if (this.checkboxValue1.length == 0) return uni.showToast({
  80. icon: 'none',
  81. title: '请勾选用户协议',
  82. position: "bottom",
  83. mask: true
  84. })
  85. if (e.detail.errMsg == 'getPhoneNumber:ok') {
  86. wx.login({
  87. success(res) {
  88. if (res.code) {
  89. wx.getUserInfo({
  90. success: function(rest) {
  91. this_.$u.api.tokenTwo({
  92. telCode: e.detail.code,
  93. loginCode: res.code,
  94. iv: e.detail.iv,
  95. encryptedData: e.detail.encryptedData,
  96. applets_id: uni.getAccountInfoSync().miniProgram
  97. .appId
  98. }).then(rest => {
  99. uni.showLoading({
  100. title: '登录中',
  101. mask: true
  102. });
  103. this_.$u.api.empowerToken({
  104. username: rest.data.phoneNumber,
  105. union_id: rest.data.unionid,
  106. open_id: rest.data.openid,
  107. applets_id: uni.getAccountInfoSync()
  108. .miniProgram.appId,
  109. password: md5('123456')
  110. }).then(data => {
  111. uni.hideLoading();
  112. uni.showToast({
  113. icon: 'none',
  114. title: '登录成功',
  115. position: "bottom",
  116. mask: true
  117. })
  118. setTimeout(function() {
  119. this_.$u.func.login(data)
  120. isProcurement({
  121. "param": "whether.open.share"
  122. }).then(res => {
  123. uni.setStorageSync('whether_openShare',res.data);
  124. })
  125. }, 1000);
  126. }).catch(err => {
  127. uni.hideLoading();
  128. uni.showToast({
  129. icon: 'none',
  130. title: err.error_description,
  131. position: "bottom",
  132. mask: true
  133. })
  134. })
  135. })
  136. },
  137. fail: res => {
  138. console.log(res, 121);
  139. uni.showToast({
  140. icon: 'none',
  141. title: '已拒绝授权,请重新授权',
  142. position: "bottom"
  143. })
  144. }
  145. })
  146. } else {
  147. uni.showToast({
  148. icon: 'none',
  149. title: res.errMsg,
  150. position: "bottom"
  151. })
  152. }
  153. }
  154. })
  155. } else if (e.detail.errMsg == 'getPhoneNumber:fail no permission') {
  156. uni.showToast({
  157. icon: 'none',
  158. title: '微信认证过期',
  159. position: "bottom"
  160. })
  161. } else {
  162. console.log(e.detail.errMsg)
  163. uni.showToast({
  164. icon: 'none',
  165. title: '已拒绝授权',
  166. position: "bottom"
  167. })
  168. }
  169. },
  170. }
  171. };
  172. </script>
  173. <style lang="scss" scoped>
  174. .custom-style {
  175. color: #3ab2f7;
  176. margin-top: 140rpx;
  177. box-shadow: 2px 5px 10px 1px rgba(43, 117, 250, 0.3);
  178. }
  179. .txt {
  180. font-size: 32rpx;
  181. font-weight: bold;
  182. color: #333333;
  183. }
  184. .img-a {
  185. width: 100%;
  186. height: 400rpx;
  187. }
  188. .logo {
  189. display: block;
  190. width: 281rpx;
  191. height: auto;
  192. margin: 35% auto;
  193. }
  194. .reg {
  195. font-size: 28rpx;
  196. color: #fff;
  197. height: 90rpx;
  198. line-height: 90rpx;
  199. border-radius: 50rpx;
  200. font-weight: bold;
  201. background: #f5f6fa;
  202. color: #000000;
  203. text-align: center;
  204. margin-top: 30rpx;
  205. }
  206. .login-view {
  207. width: 100%;
  208. }
  209. .t-login {
  210. width: 600rpx;
  211. margin: 0 auto;
  212. font-size: 28rpx;
  213. margin-top: 80rpx;
  214. }
  215. .t-login button {
  216. font-size: 28rpx;
  217. background: #2796f2;
  218. color: #fff;
  219. height: 90rpx;
  220. line-height: 90rpx;
  221. border-radius: 50rpx;
  222. font-weight: bold;
  223. }
  224. .t-login input {
  225. height: 90rpx;
  226. line-height: 90rpx;
  227. margin-bottom: 50rpx;
  228. border-bottom: 1px solid #e9e9e9;
  229. font-size: 28rpx;
  230. }
  231. .t-login .t-a {
  232. position: relative;
  233. }
  234. .t-b {
  235. text-align: left;
  236. font-size: 42rpx;
  237. color: #000;
  238. padding: 130rpx 0 0 70rpx;
  239. font-weight: bold;
  240. line-height: 70rpx;
  241. }
  242. .t-login .t-c {
  243. position: absolute;
  244. right: 22rpx;
  245. top: 22rpx;
  246. background: #5677fc;
  247. color: #fff;
  248. font-size: 24rpx;
  249. border-radius: 50rpx;
  250. height: 50rpx;
  251. line-height: 50rpx;
  252. padding: 0 25rpx;
  253. }
  254. .t-login .t-d {
  255. text-align: center;
  256. color: #999;
  257. margin: 80rpx 0;
  258. }
  259. .t-login .t-e {
  260. text-align: center;
  261. width: 250rpx;
  262. margin: 80rpx auto 0;
  263. }
  264. .t-login .t-g {
  265. float: left;
  266. width: 50%;
  267. }
  268. .t-login .t-e image {
  269. width: 50rpx;
  270. height: 50rpx;
  271. }
  272. .t-login .t-f {
  273. text-align: center;
  274. margin: 150rpx 0 0 0;
  275. color: #666;
  276. }
  277. .t-login .t-f text {
  278. margin-left: 20rpx;
  279. color: #aaaaaa;
  280. font-size: 27rpx;
  281. }
  282. .t-login .uni-input-placeholder {
  283. color: #aeaeae;
  284. }
  285. .cl {
  286. zoom: 1;
  287. }
  288. .cl:after {
  289. clear: both;
  290. display: block;
  291. visibility: hidden;
  292. height: 0;
  293. content: '\20';
  294. }
  295. </style>