youyue.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. <template>
  2. <view class="youyue">
  3. <view class="nav">
  4. <image src="http://t9.9026.com/imgs/logo@2x.png"></image>
  5. </view>
  6. <view class="title">
  7. IHG优悦会忠诚计划优悦随行悦享世界
  8. </view>
  9. <view class="detail">
  10. <view><text>HG优悦会是洲际酒店集团的会员忠诚计划。在全球拥有超过1亿会员。</text></view>
  11. <view><text> 即刻加入HG优悦会,一键开启会员专享价及会员专属礼遇。轻松赚取积分,使用灵活的积分兑换及竞拍,畅享独特且多元的犒赏体验。</text></view>
  12. </view>
  13. <view class="boxitem">
  14. <text class="boxitemtitle">优悦会会员权益</text>
  15. </view>
  16. <view class="boxitem" style="border-top: none;">
  17. <text class="boxitemtitle">入会第一天起即可臻享礼遇</text>
  18. </view>
  19. <view class="boxitem" style="border-top: none;">
  20. <text class="boxitemtitle">赚取酒店积分兑换奖励住宿以及更多</text>
  21. <text class="boxitemcontent">积分不仅可以兑换体验,目录商品等,还可以兑换全球6000等多个目的地奖励住宿</text>
  22. <image src="/static/icon/loginicon1.png"></image>
  23. </view>
  24. <view class="boxitem" style="border-top: none;">
  25. <text class="boxitemtitle">会员专享价</text>
  26. <text class="boxitemcontent" style="margin-bottom: 30rpx;">直接预订可享受我们会员专属的优惠房价</text>
  27. <image src="/static/icon/loginicon2.png"></image>
  28. </view>
  29. <view class="boxitem" style="border-top: none;">
  30. <text class="boxitemtitle">会员促销</text>
  31. <text class="boxitemcontent" style="margin-bottom: 30rpx;">尽情享受会员促销,赚取更多奖励积分</text>
  32. <image src="/static/icon/loginicon3.png"></image>
  33. </view>
  34. <view class="item"><text class="itemtitle">畅享网络</text></view>
  35. <view class="itemLast">我们所有酒店均提供免费WIFI,让您始终顺畅连通</view>
  36. <view class="btn" @click="goOther">
  37. <text>立即加入会员</text>
  38. </view>
  39. <view class="logintitle">
  40. <view class="line"></view>
  41. <view class="logintype"><text>其他登录</text></view>
  42. <view class="line"></view>
  43. </view>
  44. <view class="typebtn" @click="getmsg">
  45. <view class="item">
  46. <image src="/static/icon/wechart.png" mode="scaleToFill"></image>
  47. <text>微信登录</text>
  48. </view>
  49. </view>
  50. <u-modal @close="closeMask" closeOnClickOverlay="true" :show="modal.show" :title="modal.title"
  51. :show-confirm-button="false">
  52. <view>
  53. <button class="avatar" open-type="chooseAvatar" @chooseavatar="handleChooseAvatar">
  54. <image class="user-avatar" style="height: 176rpx;width: 176rpx;border-radius: 50%;"
  55. :src="modal.avatar?modal.avatar:'/static/icon/avatar.png'" />
  56. </button>
  57. <input class="avatar" type="nickname" :value="modal.nickname" placeholder="填写昵称"
  58. @change="handleChangeNickname">
  59. <button class="confirm" @click="handleConfirmWechatUserInfo">提交</button>
  60. </view>
  61. </u-modal>
  62. </view>
  63. </template>
  64. <script>
  65. export default {
  66. data() {
  67. return {
  68. imgBase64: '',
  69. isLoginOff: false,
  70. modal: {
  71. show: false,
  72. title: '用户信息获取',
  73. nickname: '',
  74. avatar: ''
  75. },
  76. code: '',
  77. encryptedData: '',
  78. iv: '',
  79. data: {}
  80. }
  81. },
  82. onLoad() {
  83. this.isLoginOff = this.$store.getters.userInfo
  84. },
  85. methods: {
  86. //关闭遮罩层
  87. closeMask() {
  88. this.modal.show = false
  89. },
  90. //提交微信名称和头像
  91. handleConfirmWechatUserInfo() {
  92. if (!this.modal.avatar) {
  93. this.$u.toast('请上传头像')
  94. return
  95. }
  96. if (!this.modal.nickname) {
  97. this.$u.toast('请填写昵称')
  98. return
  99. }
  100. this.$loading('数据提交中...')
  101. this.$api.my.update({
  102. avatar: this.modal.avatar,
  103. nickname: this.modal.nickname
  104. }).then(res => {
  105. this.$hideLoading()
  106. this.$store.dispatch('user/info', res.data)
  107. this.modal.show = false
  108. uni.switchTab({
  109. url: '/pages/my/my'
  110. })
  111. })
  112. },
  113. handleGetWechatUserInfo() {
  114. this.modal.show = true
  115. },
  116. // 微信获取头像
  117. handleChooseAvatar(e) {
  118. console.log(e.detail, '------>e.detail');
  119. this.modal.avatar = e.detail.avatarUrl
  120. // uni.getFileSystemManager().readFile({
  121. // filePath: e.detail.avatarUrl, //选择图片返回的相对路径
  122. // encoding: 'base64', //编码格式
  123. // success: res => { //成功的回调
  124. // console.log(res);
  125. // this.imgBase64 = 'data:image/jpeg;base64,' + res.data //不加上这串字符,在页面无法显示的哦
  126. // this.modal.avatar = this.imgBase64
  127. // },
  128. // fail: (e) => {
  129. // console.log("图片转换失败");
  130. // }
  131. // })
  132. },
  133. handleChangeNickname(res) {
  134. this.modal.nickname = res.detail.value
  135. },
  136. //获取当前页面路径
  137. getPageUrl() {
  138. const pages = getCurrentPages();
  139. console.log(pages,'--------->pages')
  140. if(pages.length==1){
  141. const currentPage = pages[0];
  142. let pageUrl = `/${currentPage.route}`;
  143. return pageUrl
  144. console.log('当前页面url:', pageUrl);
  145. }else{
  146. const currentPage = pages[pages.length - 1];
  147. let pageUrl = `/${currentPage.route}`;
  148. return pageUrl
  149. console.log('当前页面url:', pageUrl);
  150. }
  151. // pageUrl = this.pageUrl + '?id=' + this.detailID;
  152. },
  153. // 跳转其他小程序
  154. goOther() {
  155. let _this = this
  156. wx.navigateToMiniProgram({
  157. appId: 'wx255b58f0992b3c53', //appid
  158. path: 'newUIMain/enrollment/enrollment', //path
  159. extraData: { //参数
  160. foo: 'bar'
  161. },
  162. // envVersion: 'develop', //开发版develop 开发版 trial 体验版 release 正式版
  163. success(res) {
  164. let page = _this.getPageUrl()
  165. console.log('成功', page)
  166. _this.$api.my.userMemberAdd({
  167. user_id: 0,
  168. page,
  169. }).then(res => {
  170. console.log(res.data);
  171. })
  172. // 打开成功
  173. },
  174. fail(e) {
  175. console.log(e, '失败')
  176. }
  177. })
  178. },
  179. getCode() {
  180. return new Promise((resolve, reject) => {
  181. uni.getUserInfo({
  182. success: loginRes => {
  183. this.data.encryptData = loginRes.encryptedData,
  184. this.data.iv = loginRes.iv
  185. resolve(this.data)
  186. }
  187. })
  188. })
  189. },
  190. //获取微信登录的code码
  191. getmsg() {
  192. if (this.isLoginOff) {
  193. uni.switchTab({
  194. url: '/pages/my/my'
  195. })
  196. } else {
  197. uni.login({
  198. provider: uni.$u.platform,
  199. success: res => {
  200. this.getCode().then((data) => {
  201. const params = {
  202. code: res.code,
  203. iv: data.iv,
  204. encryptData: data.encryptData
  205. }
  206. console.log(params);
  207. this.$api.my.myLogin(params).then(res => {
  208. let {
  209. token
  210. } = res.data
  211. this.$store.dispatch('user/token', token)
  212. this.handleGetWechatUserInfo()
  213. this.handleConfirmWechatUserInfo()
  214. })
  215. })
  216. }
  217. })
  218. }
  219. },
  220. }
  221. }
  222. </script>
  223. <style lang="scss" scoped>
  224. $pageColor:#F9F9F9;
  225. $bgColor:#FFFFFF;
  226. .youyue {
  227. height: 100%;
  228. background: $bgColor;
  229. padding: 192rpx 30rpx 140rpx 30rpx;
  230. position: relative;
  231. }
  232. .avatar {
  233. width: 176rpx;
  234. height: 176rpx;
  235. border-radius: 50%;
  236. }
  237. .user-avatar {
  238. object-fit: cover;
  239. object-position: center;
  240. }
  241. .userinfo {
  242. position: absolute;
  243. top: 38rpx;
  244. left: 200rpx;
  245. .unlogin {
  246. width: 220rpx;
  247. font-size: 44rpx;
  248. font-family: PingFang-SC-Heavy, PingFang-SC;
  249. font-weight: 500;
  250. color: #FFFFFF;
  251. display: block;
  252. margin-top: 20rpx;
  253. }
  254. .username {
  255. width: 184rpx;
  256. height: 44rpx;
  257. font-size: 44rpx;
  258. font-family: PingFang-SC-Heavy, PingFang-SC;
  259. font-weight: 500;
  260. color: #FFFFFF;
  261. line-height: 44rpx;
  262. display: block;
  263. margin-bottom: 24rpx;
  264. }
  265. .userId {
  266. font-size: 32rpx;
  267. font-family: PingFang-SC-Medium, PingFang-SC;
  268. font-weight: 400;
  269. color: #FFFFFF;
  270. line-height: 32rpx;
  271. }
  272. }
  273. .nav {
  274. position: absolute;
  275. top: 0rpx;
  276. left: 0rpx;
  277. image {
  278. width: 750rpx;
  279. height: 142rpx;
  280. }
  281. }
  282. .title {
  283. width: 400rpx;
  284. height: 120rpx;
  285. font-size: 44rpx;
  286. font-family: PingFang-SC-Bold, PingFang-SC;
  287. font-weight: bold;
  288. color: #333333;
  289. line-height: 60rpx;
  290. margin-bottom: 64rpx;
  291. }
  292. .detail {
  293. width: 690rpx;
  294. height: 220rpx;
  295. margin-bottom: 64rpx;
  296. text {
  297. font-size: 32rpx;
  298. font-family: PingFang-SC-Medium, PingFang-SC;
  299. font-weight: 500;
  300. color: #333333;
  301. }
  302. }
  303. .item {
  304. margin: 40rpx 0;
  305. .itemtitle {
  306. font-size: 32rpx;
  307. font-family: PingFang-SC-Bold, PingFang-SC;
  308. font-weight: bold;
  309. color: #333333;
  310. }
  311. }
  312. .itemLast {
  313. width: 690rpx;
  314. font-size: 24rpx;
  315. font-family: PingFang-SC-Medium, PingFang-SC;
  316. font-weight: 500;
  317. color: #333333;
  318. margin-bottom: 64rpx;
  319. }
  320. .btn {
  321. width: 688rpx;
  322. height: 92rpx;
  323. background: linear-gradient(270deg, #FF6200 0%, #FF9342 100%);
  324. display: flex;
  325. align-items: center;
  326. justify-content: center;
  327. border-radius: 12rpx;
  328. text {
  329. font-size: 30rpx;
  330. font-family: PingFang-SC-Bold, PingFang-SC;
  331. font-weight: bold;
  332. color: #FFFFFF;
  333. }
  334. }
  335. .logintitle {
  336. height: 40rpx;
  337. width: 690rpx;
  338. margin-top: 64rpx;
  339. margin-bottom: 64rpx;
  340. display: flex;
  341. align-items: center;
  342. justify-content: space-between;
  343. .line {
  344. width: 240rpx;
  345. height: 2rpx;
  346. background: #EDEDED;
  347. border-radius: 1rpx;
  348. }
  349. .logintype {
  350. text {
  351. font-size: 28rpx;
  352. font-family: PingFang-SC-Medium, PingFang-SC;
  353. font-weight: 500;
  354. color: #333333;
  355. }
  356. }
  357. }
  358. .typebtn {
  359. display: flex;
  360. align-items: center;
  361. justify-content: space-around;
  362. .item {
  363. width: 140rpx;
  364. height: 156rpx;
  365. display: flex;
  366. flex-direction: column;
  367. align-items: center;
  368. justify-content: center;
  369. image {
  370. width: 104rpx;
  371. height: 104rpx;
  372. margin-bottom: 12rpx;
  373. }
  374. text {
  375. display: block;
  376. font-size: 28rpx;
  377. font-family: PingFang-SC-Medium, PingFang-SC;
  378. font-weight: 500;
  379. color: #666666;
  380. }
  381. }
  382. }
  383. .boxitem {
  384. border-top: #F0F0F0 2rpx solid;
  385. border-bottom: #F0F0F0 2rpx solid;
  386. padding: 40rpx 0;
  387. position: relative;
  388. image {
  389. top: 35%;
  390. right: 0rpx;
  391. width: 96rpx;
  392. height: 96rpx;
  393. position: absolute;
  394. }
  395. .boxitemtitle {
  396. font-size: 32rpx;
  397. font-family: PingFang-SC-Bold, PingFang-SC;
  398. font-weight: bold;
  399. color: #333333;
  400. }
  401. .boxitemcontent {
  402. margin-top: 24rpx;
  403. width: 512rpx;
  404. display: block;
  405. font-size: 28rpx;
  406. font-family: PingFang-SC-Medium, PingFang-SC;
  407. font-weight: 500;
  408. color: #333333;
  409. }
  410. }
  411. </style>