login.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. <template>
  2. <view class="container">
  3. <view class="login-wrap">
  4. <view class="title">
  5. <text>HI,您好! 欢迎登录</text>
  6. </view>
  7. <view class="h-logo">
  8. <image class="logo-img" src="../../static/logo.png" mode=""></image>
  9. </view>
  10. <!-- <button class="login-btn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
  11. <u-icon name="weixin-fill" color="green" size="26"></u-icon>
  12. 微信授权手机号登录
  13. </button> -->
  14. <button class="login-btn" @click="wechatCodeLogin()">
  15. <!-- <u-icon name="weixin-fill" color="green" size="26"></u-icon>-->
  16. 快捷登录
  17. </button>
  18. <view class="guest-btn" @click="goBack()">
  19. <text>暂不登录,先逛逛</text>
  20. </view>
  21. <!-- <view class="login-form">-->
  22. <!-- <view class="remember-acconut">-->
  23. <!-- <view class="remember-acconut-password">-->
  24. <!-- <u-radio-group-->
  25. <!-- v-model="radiovalue1"-->
  26. <!-- placement="column"-->
  27. <!-- @change="groupChange"-->
  28. <!-- >-->
  29. <!-- <u-radio-->
  30. <!-- :customStyle="{marginBottom: '8px'}"-->
  31. <!-- v-for="(item, index) in radiolist1"-->
  32. <!-- :key="index"-->
  33. <!-- :label="item.name"-->
  34. <!-- :name="item.name"-->
  35. <!-- @change="radioChange"-->
  36. <!-- >-->
  37. <!-- </u-radio>-->
  38. <!-- </u-radio-group>-->
  39. <!-- </view>-->
  40. <!-- <view @click="gotoRetieveAccount()" class="forget-acconut-password">-->
  41. <!-- 找回账号-->
  42. <!-- </view>-->
  43. <!-- </view>-->
  44. <!-- </view>-->
  45. <view class="login-form">
  46. <!-- <text style="color: red;font-size: 22rpx ">*此账号密码可进行交易使用,请保存好您的隐私。</text>-->
  47. <view class="agreement-content">
  48. <u-icon v-if="choose" name="/static/order/isCheck.png" color="#2979ff" size="20" @click="changeChoose"></u-icon>
  49. <u-icon v-else name="/static/order/notCheck.png" color="#FFE05C" size="20" @click="changeChoose"></u-icon>
  50. <view class="agreement">
  51. <text>允许我们在必要的场景下合理使用你的相关信息,请阅读并同意</text>
  52. <text @click="gotoAgreement('1','会员须知')" class="text-color">《会员须知》、</text>
  53. <text @click="gotoAgreement('3','隐私政策')" class="text-color">《隐私政策》</text>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <!-- 判断微信是否绑定账号 -->
  59. <u-popup :show="show" :round="10" mode="center">
  60. <view class="h-popo-content">
  61. <view class="h-img">
  62. <u-icon name="/static/login/u01.png" color="red" size="60"></u-icon>
  63. </view>
  64. <view class="text">
  65. <text>该微信未绑定账号</text>
  66. </view>
  67. <view class="h-btn-wrap">
  68. <view @click="cancelOption" class="h-left-btn">
  69. <text>取消</text>
  70. </view>
  71. <view @click="gotoBindAccount" class="h-right-btn">
  72. <text>去绑定</text>
  73. </view>
  74. </view>
  75. </view>
  76. </u-popup>
  77. </view>
  78. </template>
  79. <script>
  80. export default {
  81. data() {
  82. return {
  83. choose:false,
  84. show: false,
  85. userInfo: {
  86. username: 'uview-plus UI',
  87. password: '',
  88. openId: ''
  89. },
  90. // 基本案列数据
  91. radiolist1: [{
  92. name: '自动登录',
  93. disabled: true
  94. }],
  95. radiolist2: [{
  96. name: '允许我们在必要的场景下合理使用你的相关信息,登录且同意',
  97. disabled: true
  98. }],
  99. // u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
  100. radiovalue1: '自动登录',
  101. radiovalue2: '22222',
  102. };
  103. },
  104. onLoad() {
  105. // this.wechatCodeLogin();
  106. },
  107. methods: {
  108. changeChoose(){
  109. this.choose =!this.choose
  110. },
  111. // 去协议页面
  112. gotoAgreement(type, name) {
  113. uni.navigateTo({
  114. url: '/myPages/TermsOfService/index?name=' + name + '&type=' + type,
  115. })
  116. },
  117. // 取消操作
  118. cancelOption() {
  119. this.show = false;
  120. },
  121. // 去绑定账号
  122. gotoBindAccount() {
  123. this.show = false;
  124. uni.navigateTo({
  125. url: '/loginPages/login/bind-account',
  126. })
  127. },
  128. // 自动登录不成功,用户手动授权登录
  129. authWechatCodeLogin() {
  130. if (this.userInfo == undefined) {
  131. this.show = true;
  132. }
  133. },
  134. // 微信小程序code自动登录
  135. wechatCodeLogin() {
  136. let that = this;
  137. if (!this.choose){
  138. uni.$u.toast('请阅读条款并勾选注册')
  139. return
  140. }
  141. wx.login({
  142. success(re) {
  143. that.$api.wxLogin({code:re.code}).then(res=>{
  144. uni.setStorageSync('userInfo',res.data.data.userInfo)
  145. uni.setStorageSync('accessToken',res.data.data.access_token)
  146. uni.setStorageSync('phoneIsBind',res.data.data.phoneIsBind)
  147. uni.removeStorageSync('parent_member_id');
  148. // if (!res.data.data.phoneIsBind){
  149. // uni.showModal({
  150. // title:'温馨提示',
  151. // content:'请绑定手机号,以便为你提供服务',
  152. // success:res=>{
  153. // if (res.confirm){
  154. // uni.navigateTo({
  155. // url: '/myPages/setting/setting-telphone',
  156. // })
  157. // }
  158. // }
  159. // })
  160. // }else {
  161. uni.switchTab({
  162. url: '/pages/index/index',
  163. })
  164. // }
  165. })
  166. },
  167. fail(err){
  168. console.log('出错了++++++++++++++++',err)
  169. }
  170. })
  171. },
  172. getPhoneNumber(e) {
  173. uni.showToast({
  174. title: e.detail.code
  175. })
  176. console.log(e.detail.code) // 动态令牌
  177. console.log(e.detail.errMsg) // 回调信息(成功失败都会返回)
  178. console.log(e.detail.errno) // 错误码(失败时返回)
  179. },
  180. // 返回首页(游客模式)
  181. goBack() {
  182. uni.switchTab({
  183. url: '/pages/index/index',
  184. })
  185. },
  186. // 去找回账号页面
  187. gotoRetieveAccount() {
  188. uni.navigateTo({
  189. url: '/loginPages/login/retrieve-account',
  190. })
  191. },
  192. groupChange(n) {
  193. console.log('groupChange', n);
  194. },
  195. radioChange(n) {
  196. this.radiovalue1 = ""
  197. console.log('radioChange', n);
  198. },
  199. },
  200. };
  201. </script>
  202. <style lang="scss">
  203. page,
  204. body {
  205. background: #fff;
  206. }
  207. .container {
  208. width: 90%;
  209. margin: 0 auto;
  210. font-family: PingFangSC-Semibold, PingFang SC;
  211. .title {
  212. margin-top: 12px;
  213. width: 140px;
  214. font-size: 24px;
  215. font-weight: 600;
  216. color: #333333;
  217. line-height: 38px;
  218. }
  219. .h-logo {
  220. text-align: center;
  221. .logo-img {
  222. width: 160px;
  223. height: 122px;
  224. }
  225. }
  226. .login-wrap {
  227. .account {
  228. display: flex;
  229. }
  230. }
  231. .login-btn {
  232. text-align: center;
  233. color: #333;
  234. width: 70%;
  235. justify-content: center;
  236. margin: 0 auto;
  237. margin-top: 50px;
  238. height: 40px;
  239. line-height: 40px;
  240. border-radius: 8px;
  241. background: #FFE05C;
  242. border-radius: 21px;
  243. font-size: 14px;
  244. display: flex;
  245. .wechat-logo {
  246. height: 12px;
  247. width: 12px;
  248. }
  249. }
  250. .guest-btn {
  251. text-align: center;
  252. width: 70%;
  253. margin: 0 auto;
  254. margin-top: 20px;
  255. height: 40px;
  256. line-height: 40px;
  257. font-size: 14px;
  258. color: #999;
  259. }
  260. .identifying-code {
  261. image {
  262. width: 80px;
  263. height: 30px;
  264. }
  265. }
  266. .remember-acconut {
  267. margin-top: 18px;
  268. display: flex;
  269. justify-content: space-between;
  270. color: #999999;
  271. .forget-acconut-password {
  272. color: rgb(96, 98, 102);
  273. font-size: 15px;
  274. line-height: 25px;
  275. margin-left: 30%;
  276. }
  277. }
  278. .agreement-content {
  279. margin-top: 18px;
  280. display: flex;
  281. // justify-content: space-between;
  282. color: #999999;
  283. align-items: center;
  284. .agreement {
  285. color: rgb(96, 98, 102);
  286. padding-left: 1px;
  287. font-size: 28rpx;
  288. .text-color {
  289. color: red;
  290. }
  291. }
  292. }
  293. }
  294. .h-popo-content {
  295. height: 180px;
  296. padding: 12px;
  297. width: 300px;
  298. text-align: center;
  299. font-size: 14px;
  300. font-family: PingFangSC-Semibold, PingFang SC;
  301. .h-img {
  302. padding: 7px;
  303. display: flex;
  304. justify-content: center;
  305. }
  306. .h-text {
  307. margin-top: 12px;
  308. font-weight: 400;
  309. color: #666666;
  310. }
  311. .text {
  312. margin-top: 6px;
  313. font-weight: 400;
  314. color: #666666;
  315. }
  316. .h-btn-wrap {
  317. display: flex;
  318. justify-content: space-between;
  319. color: #333333;
  320. text-align: center;
  321. margin-top: 14px;
  322. .h-left-btn {
  323. height: 32px;
  324. line-height: 30px;
  325. background: #EEEEEE;
  326. width: 100px;
  327. text-align: center;
  328. border-radius: 16px;
  329. margin: 0 auto;
  330. }
  331. .h-right-btn {
  332. height: 32px;
  333. line-height: 30px;
  334. background: #FFE05C;
  335. width: 100px;
  336. border-radius: 16px;
  337. margin: 0 auto;
  338. }
  339. }
  340. }
  341. </style>