login.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <template>
  2. <view class="container">
  3. <view class="head">
  4. <view class="head-image">
  5. <image :src="defaultavatarUrl" mode="" style="border-radius: 50%; width: 100%;height: 100%;">
  6. </image>
  7. </view>
  8. <view class="head-text">
  9. <p style="font-weight:bold;font-size: 35rpx;padding-bottom: 20rpx;">样叽</p>
  10. <p style="font-weight:bold;font-size: 35rpx;">YounGee</p>
  11. </view>
  12. </view>
  13. <view class="body">
  14. <button class="login-btn" @click="toggle('bottom')">微信授权</button>
  15. <button class="exit-btn" @click="exit()">取消登录</button>
  16. <view class="xieyi">
  17. <uni-data-checkbox multiple class="xieyi-btn" v-model="value" :localdata="range" @change="select">
  18. </uni-data-checkbox>
  19. <p class="xieyi-read">阅读并同意</p>
  20. <a class="xieyi-content" src="">《用户协议及隐私政策》</a>
  21. </view>
  22. </view>
  23. <view>
  24. <!-- 底部普通弹窗 -->
  25. <uni-popup ref="popup" background-color="#fff" @change="change" style="border-radius: 20rpx;">
  26. <view class="popup-content" :class="{ 'popup-height': type === 'left' || type === 'right' }"
  27. style=" ">
  28. <view class=""
  29. style="width: 90%; margin: 0 auto; margin-top: 10% !important;margin-bottom: 10% !important;">
  30. <view class="Tasktext">
  31. <image :src="picture.task15" mode=""></image>
  32. <span>YoungGee申请使用</span>
  33. </view>
  34. <view class="">
  35. <h5>你的微信头像、昵称、地区及性别信息</h5>
  36. </view>
  37. <!-- 黑线 -->
  38. <view class="" style="border-bottom: 2rpx solid #C0C0C0;margin-top: 3%;margin-bottom: 3%;">
  39. </view>
  40. <view class="" style="display: flex;justify-content:space-around;">
  41. <image :src="picture.jpg7" mode=""
  42. style="width: 84rpx;height: 84rpx;border-radius: 10rpx;">
  43. </image>
  44. <view class="" style="width: 70%;">
  45. <p style='color: #000000; font-size: 28rpx;'>昵称</p>
  46. <p style='color: #999999; font-size: 24rpx;margin-top: 2%;'>微信个人信息</p>
  47. </view>
  48. <view class="" style="margin-top: 3%;">
  49. <image :src="picture.png6" mode="" style="width: 32rpx;height: 22rpx;"></image>
  50. </view>
  51. </view>
  52. <!-- 黑线 -->
  53. <view class="" style="border-bottom: 2rpx solid #C0C0C0;margin-top: 3%;margin-bottom: 3%;">
  54. </view>
  55. <view class="butto" style="margin-top: 3%;">
  56. <button class="mini-btn" size="mini" @tap="Reset"
  57. style="background-color: #F2F2F2;color:#20AC19 ; margin-right: 5%;">拒绝</button>
  58. <button class="mini-btn" size="mini" @tap="determine"
  59. style="background-color: #20AC19;color:#F2F2F2 ;margin-left: 5%;">允许</button>
  60. </view>
  61. </view>
  62. </view>
  63. </uni-popup>
  64. </view>
  65. </view>
  66. </template>
  67. <script>
  68. export default {
  69. data() {
  70. return {
  71. value: 0,
  72. range: [{
  73. "value": 1,
  74. "text": ""
  75. }],
  76. defaultavatarUrl: 'https://horastar.obs.cn-east-3.myhuaweicloud.com/talent/logoxin01.png',
  77. picture: {
  78. home8: 'https://horastar.obs.cn-east-3.myhuaweicloud.com/talent/home8.png',
  79. deng5: 'https://horastar.obs.cn-east-3.myhuaweicloud.com/talent/deng5.png',
  80. deng1: 'https://horastar.obs.cn-east-3.myhuaweicloud.com/talent/deng1.png',
  81. task15: 'https://horastar.obs.cn-east-3.myhuaweicloud.com/talent/task15.png',
  82. jpg7: 'https://horastar.obs.cn-east-3.myhuaweicloud.com/talent/7.jpg',
  83. png6: 'https://horastar.obs.cn-east-3.myhuaweicloud.com/talent/6.png'
  84. },
  85. type: 'center',
  86. nickname: '',
  87. gender: '',
  88. };
  89. },
  90. onLoad() {},
  91. methods: {
  92. select() {
  93. console.log(this.value)
  94. },
  95. //swiper滑动事件
  96. swiperChange: function(e) {
  97. this.swiper.index = e.detail.current;
  98. },
  99. //底部弹出层
  100. change(e) {
  101. console.log('当前模式:' + e.type + ',状态:' + e.show);
  102. },
  103. exit() {
  104. uni.navigateBack()
  105. },
  106. toggle(type) {
  107. //新版登录方式
  108. if (this.value.length !== 1) {
  109. uni.showToast({
  110. title: '请先阅读并同意协议',
  111. icon: 'none',
  112. duration: 2000
  113. });
  114. return;
  115. }
  116. uni.getUserProfile({
  117. desc: '登录',
  118. success: (res) => {
  119. //console.log(res);
  120. console.log(res)
  121. this.nickname = res.userInfo.nickName
  122. this.gender = res.userInfo.gender
  123. uni.setStorageSync('nickName', res.userInfo.nickName);
  124. uni.setStorageSync('avatarUrl', res.userInfo.avatarUrl);
  125. try {
  126. this.login();
  127. } catch (e) {}
  128. },
  129. fail: (res) => {
  130. console.log(res)
  131. }
  132. });
  133. },
  134. // 获取手机号
  135. onGetPhoneNumber(e) {
  136. if (e.detail.errMsg == "getPhoneNumber:fail user deny") { //用户决绝授权
  137. //拒绝授权后弹出一些提示
  138. } else {
  139. //允许授权
  140. console.log(e)
  141. this.$refs.popup.open('bottom')
  142. e.detail.encryptedData //加密的用户信息
  143. e.detail.iv //加密算法的初始向量 时要用到
  144. }
  145. },
  146. //登录
  147. login() {
  148. let _this = this;
  149. // 获取登录用户code
  150. uni.login({
  151. provider: 'weixin',
  152. onlyAuthorize: true,
  153. success: function(res) {
  154. // console.log(res);
  155. if (res.code) {
  156. let code = res.code;
  157. _this.$https.post('/youngee/c/p/login', {
  158. code: res.code, //wx.login 登录成功后的code
  159. gender: _this.gender,
  160. nickname: _this.nickname
  161. })
  162. .then(res => {
  163. if (res.data.code == -6) {
  164. uni.showToast({
  165. title: '您已被拉黑,请联系客服',
  166. icon: 'none',
  167. duration: 2000
  168. });
  169. } else {
  170. console.log(res)
  171. uni.setStorageSync('token', res.data.data.token);
  172. uni.setStorageSync('cookie', res.header['Set-Cookie']);
  173. uni.navigateBack()
  174. }
  175. })
  176. // uni.request({
  177. // url: 'http://localhost:8199/youngee/c/p/login', //演示地址,请以你的后端接口为准
  178. // method: 'POST',
  179. // data: {
  180. // code: res.code, //wx.login 登录成功后的code
  181. // gender: _this.gender,
  182. // nickname: _this.nickname
  183. // },
  184. // success: (cts) => {
  185. // if (cts.data.code == -6) {
  186. // uni.showToast({
  187. // title: '您已被拉黑,请联系客服',
  188. // icon: 'none',
  189. // duration: 2000
  190. // });
  191. // } else {
  192. // console.log(cts)
  193. // uni.setStorageSync('token', cts.data.data.token);
  194. // uni.setStorageSync('cookie', cts.header['Set-Cookie']);
  195. // uni.navigateBack()
  196. // }
  197. // }
  198. // });
  199. } else {
  200. uni.showToast({
  201. title: '登录失败!',
  202. duration: 2000
  203. });
  204. console.log('登录失败!' + res.errMsg)
  205. }
  206. }
  207. });
  208. },
  209. determine() {
  210. uni.showToast({
  211. title: "登录成功",
  212. duration: 1000,
  213. });
  214. this.$refs.popup.close()
  215. },
  216. xieyi() {
  217. console.log('进入协议')
  218. },
  219. }
  220. }
  221. </script>
  222. <style>
  223. .content {
  224. border-radius: 20rpx 20rpx 0 0 !important;
  225. }
  226. </style>
  227. <style lang="scss" scoped>
  228. .head {
  229. display: flex;
  230. align-items: center;
  231. /* 垂直居中 */
  232. height: 200rpx;
  233. margin-top: 30%;
  234. margin-bottom: 20%;
  235. }
  236. .head-image {
  237. display: inline-block;
  238. margin: 0 50rpx 0 150rpx;
  239. width: 160rpx;
  240. height: 160rpx;
  241. background-color: #F0D232;
  242. border-radius: 50%;
  243. }
  244. .login-btn {
  245. margin: 30rpx;
  246. font-size: 35rpx;
  247. background-color: #F0D232;
  248. border: none;
  249. border-radius: 10rpx;
  250. }
  251. .exit-btn {
  252. margin: 30rpx;
  253. font-size: 35rpx;
  254. border: 1rpx solid #000000;
  255. border-radius: 10rpx;
  256. }
  257. .xieyi {
  258. display: flex;
  259. align-items: center;
  260. justify-content: center;
  261. }
  262. .xieyi-btn {
  263. width: 40rpx;
  264. display: inline-block;
  265. font-size: 25rpx;
  266. }
  267. .xieyi-content {
  268. display: inline-block;
  269. font-size: 25rpx;
  270. }
  271. .xieyi-read {
  272. display: inline-block;
  273. font-size: 25rpx;
  274. }
  275. /deep/ .content {
  276. border-radius: 20rpx 20rpx 0 0 !important;
  277. }
  278. .Tasktext {
  279. // padding-top: 5%;
  280. padding: 0 0 0 1%;
  281. height: 80rpx;
  282. }
  283. .Tasktext span {
  284. color: #333333;
  285. font-size: 40%;
  286. font-weight: 550;
  287. text-indent: 2em;
  288. }
  289. .TitleText1 p {
  290. color: #333333;
  291. font-size: 50%;
  292. }
  293. .Tasktext {
  294. // height: 70rpx;
  295. }
  296. .Tasktext image {
  297. vertical-align: middle;
  298. width: 50rpx;
  299. height: 50rpx;
  300. display: inline-block;
  301. padding-right: 14rpx;
  302. }
  303. .butto {
  304. text-align: center;
  305. }
  306. .mini-btn {
  307. height: 55rpx;
  308. width: 150rpx;
  309. line-height: 55rpx;
  310. margin: 30rpx;
  311. }
  312. .diagram {
  313. padding-top: 30%;
  314. }
  315. .but {
  316. width: 80%;
  317. height: 60rpx;
  318. background-color: #FFD700;
  319. border-radius: 30rpx;
  320. border: 6rpx solid #0C0A03;
  321. text-align: center;
  322. line-height: 60rpx;
  323. margin: 0 auto;
  324. position: relative;
  325. font-size: 30rpx;
  326. font-weight: 550;
  327. letter-spacing: 7px;
  328. }
  329. .but span {
  330. font-size: 30rpx;
  331. font-weight: 550;
  332. letter-spacing: 7px;
  333. }
  334. .bei {
  335. // position: relative;
  336. }
  337. .mark {
  338. position: absolute;
  339. width: 8rpx;
  340. height: 8rpx;
  341. border: 2rpx solid #0C0A03;
  342. border-radius: 20px;
  343. background-color: #1E90FF;
  344. }
  345. .butt {
  346. text-align: center;
  347. padding-top: 10rpx;
  348. }
  349. .butt span {
  350. font-size: 24rpx;
  351. color: #969696;
  352. }
  353. </style>