youyue.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. <template>
  2. <view class="youyue">
  3. <view class="">
  4. <u-parse :content="memberInfo"></u-parse>
  5. </view>
  6. <!-- <view class="nav">
  7. <image src="http://t9.9026.com/imgs/logo@2x.png"></image>
  8. </view>
  9. <view class="title">
  10. IHG优悦会忠诚计划优悦随行悦享世界
  11. </view>
  12. <view class="detail">
  13. <view><text>IHG优悦会是洲际酒店集团的会员忠诚计划。在全球拥有超过1亿会员。</text></view>
  14. <view><text> 即刻加入HG优悦会,一键开启会员专享价及会员专属礼遇。轻松赚取积分,使用灵活的积分兑换及竞拍,畅享独特且多元的犒赏体验。</text></view>
  15. </view>
  16. <view class="boxitem">
  17. <text class="boxitemtitle">优悦会会员权益</text>
  18. </view>
  19. <view class="boxitem" style="border-top: none;">
  20. <text class="boxitemtitle">入会第一天起即可臻享礼遇</text>
  21. </view>
  22. <view class="boxitem" style="border-top: none;">
  23. <text class="boxitemtitle">赚取酒店积分兑换奖励住宿以及更多</text>
  24. <text class="boxitemcontent">积分不仅可以兑换体验,目录商品等,还可以兑换全球6000等多个目的地奖励住宿</text>
  25. <image src="/static/icon/loginicon1.png"></image>
  26. </view>
  27. <view class="boxitem" style="border-top: none;">
  28. <text class="boxitemtitle">会员专享价</text>
  29. <text class="boxitemcontent" style="margin-bottom: 30rpx;">直接预订可享受我们会员专属的优惠房价</text>
  30. <image src="/static/icon/loginicon2.png"></image>
  31. </view>
  32. <view class="boxitem" style="border-top: none;">
  33. <text class="boxitemtitle">会员促销</text>
  34. <text class="boxitemcontent" style="margin-bottom: 30rpx;">尽情享受会员促销,赚取更多奖励积分</text>
  35. <image src="/static/icon/loginicon3.png"></image>
  36. </view>
  37. <view class="item"><text class="itemtitle">畅享网络</text></view>
  38. <view class="itemLast">我们所有酒店均提供免费WIFI,让您始终顺畅连通</view> -->
  39. <view class="btn" @click="goOther">
  40. <text>立即加入会员</text>
  41. </view>
  42. <view class="logintitle">
  43. <view class="line"></view>
  44. <view class="logintype"><text>其他登录</text></view>
  45. <view class="line"></view>
  46. </view>
  47. <view class="typebtn" @click="getmsg">
  48. <view class="item">
  49. <image src="/static/icon/wechart.png" mode="scaleToFill"></image>
  50. <text>微信登录</text>
  51. </view>
  52. </view>
  53. <!-- <u-modal @close="closeMask" closeOnClickOverlay="true" :show="modal.show" :title="modal.title"
  54. :show-confirm-button="false">
  55. <view>
  56. <button class="avatar" open-type="chooseAvatar" @chooseavatar="handleChooseAvatar">
  57. <image class="user-avatar" style="height: 176rpx;width: 176rpx;border-radius: 50%;"
  58. :src="modal.avatar?modal.avatar:'/static/icon/avatar.png'" />
  59. </button>
  60. <input class="avatar" type="nickname" :value="modal.nickname" placeholder="填写昵称"
  61. @change="handleChangeNickname">
  62. <button class="confirm" @click="handleConfirmWechatUserInfo">提交</button>
  63. </view>
  64. </u-modal> -->
  65. <u-popup :show="modal.show" :round="10" mode="bottom" @close="close">
  66. <view class="popup-login">
  67. <view class="popup-login-top">
  68. <image style="width: 56rpx; height: 56rpx; margin-right: 20rpx; "
  69. src="https://t9.9026.com/imgs/loginLogo1.png" mode=""></image>
  70. <text>登录后体验更多功能</text>
  71. </view>
  72. <view class="popup-login-main">
  73. <button class="avatar" open-type="chooseAvatar" @chooseavatar="handleChooseAvatar">
  74. <image class="user-avatar" style="height: 176rpx;width: 176rpx;border-radius: 50%;"
  75. :src="modal.avatar?modal.avatar:'https://t9.9026.com/imgs/loginAvatar.png'" />
  76. </button>
  77. </view>
  78. <view class="popup-login-ipt">
  79. <input class="avatar" type="nickname" :value="modal.nickname" placeholder="输入昵称"
  80. @change="handleChangeNickname">
  81. </view>
  82. <view class="popup-login-btn" @click="handleConfirmWechatUserInfo">
  83. <button class="confirm">完成</button>
  84. </view>
  85. <view class="popup-login-text">
  86. <view style="display: flex;align-items: center;justify-content: center;">
  87. <text>登录即代表已阅读并同意</text>
  88. <view style="color: #FF6200;display: flex;align-items: center;justify-content: center;">
  89. <view @click="goAgreement">服务协议</view>
  90. <view @click="goPrivacy">、隐私协议</view>
  91. </view>
  92. </view>
  93. </view>
  94. </view>
  95. </u-popup>
  96. </view>
  97. </template>
  98. <script>
  99. export default {
  100. data() {
  101. return {
  102. //页面信息
  103. memberInfo:'',
  104. //跳转h5,小程序,其他页面
  105. jump_type: '',
  106. jump_config: {},
  107. //加入会员广告配置
  108. advise: '',
  109. imgBase64: '',
  110. isLoginOff: false,
  111. modal: {
  112. show: false,
  113. title: '用户信息获取',
  114. nickname: '',
  115. avatar: ''
  116. },
  117. code: '',
  118. encryptedData: '',
  119. iv: '',
  120. data: {}
  121. }
  122. },
  123. onLoad() {
  124. this.isLoginOff = this.$store.getters.userInfo
  125. this.advise = this.$store.getters.allset.add_member
  126. this.memberInfo = this.advise.value.member_info
  127. if(this.advise){
  128. this.jump_type = this.advise.value.member_info_jump_type
  129. if( this.jump_type == 1){
  130. this.jump_config = this.advise.value.member_info_h5_url
  131. }else if(this.jump_type == 2){
  132. this.jump_config.appid = this.advise.value.member_info_appid
  133. this.jump_config.path = this.advise.value.member_info_path
  134. }else if(this.jump_type == 3){
  135. this.jump_config =this.advise.value.member_info_other_path
  136. }
  137. }
  138. },
  139. methods: {
  140. //服务协议
  141. goAgreement() {
  142. console.log(111);
  143. uni.navigateTo({
  144. url: '/pages/my/protocol/UserAgreement'
  145. })
  146. },
  147. //隐私协议
  148. goPrivacy() {
  149. console.log(222);
  150. uni.navigateTo({
  151. url: '/pages/my/protocol/PrivacyPolicy'
  152. })
  153. },
  154. // 跳转其他小程序
  155. goOther() {
  156. this.jumpHAppID(this.jump_type, this.jump_config)
  157. },
  158. jumpHAppID(id, urls) {
  159. if (id == 1) {
  160. const url = urls; // 跳转的外链
  161. const navtitle = 'H5'; // 这个标题是你自己可以设置的
  162. uni.navigateTo({
  163. // 跳转到webview页面
  164. url: `/pages/webview/webview?url=${url}&nav=${navtitle}`,
  165. success: () => {
  166. console.log('成功')
  167. },
  168. fail: (e) => {
  169. console.log(e, "失败")
  170. }
  171. });
  172. } else if (id == 2) {
  173. let _this = this
  174. let obj = urls;
  175. console.log(obj, '----->obj');
  176. wx.navigateToMiniProgram({
  177. appId: `${obj.appid}`, //appid
  178. path: `${obj.path}`, //path
  179. extraData: { //参数
  180. foo: 'bar'
  181. },
  182. // envVersion: 'develop', //开发版develop 开发版 trial 体验版 release 正式版
  183. success(res) {
  184. let page = _this.getPageUrl()
  185. console.log('成功', page)
  186. _this.$api.my.userMemberAdd({
  187. user_id: 0,
  188. page,
  189. }).then(res => {
  190. console.log(res.data);
  191. })
  192. // 打开成功
  193. },
  194. fail(e) {
  195. console.log(e, '失败')
  196. }
  197. })
  198. } else if (id == 3) {
  199. uni.redirectTo({
  200. url: urls,
  201. fail: (err) => {
  202. uni.reLaunch({
  203. url: urls
  204. })
  205. }
  206. })
  207. }
  208. },
  209. //关闭遮罩层
  210. closeMask() {
  211. this.modal.show = false
  212. },
  213. close() {
  214. this.modal.show = false
  215. },
  216. //提交微信名称和头像
  217. handleConfirmWechatUserInfo() {
  218. if (!this.modal.avatar) {
  219. this.$u.toast('请上传头像')
  220. return
  221. }
  222. if (!this.modal.nickname) {
  223. this.$u.toast('请填写昵称')
  224. return
  225. }
  226. this.$loading('数据提交中...')
  227. this.$api.my.update({
  228. avatar: this.modal.avatar,
  229. nickname: this.modal.nickname
  230. }).then(res => {
  231. this.$hideLoading()
  232. this.$store.dispatch('user/info', res.data)
  233. this.modal.show = false
  234. uni.switchTab({
  235. url: '/pages/my/my'
  236. })
  237. })
  238. },
  239. handleGetWechatUserInfo() {
  240. this.modal.show = true
  241. },
  242. // 微信获取头像
  243. handleChooseAvatar({
  244. detail
  245. }) {
  246. let _this = this
  247. uni.getFileSystemManager().readFile({
  248. filePath: detail.avatarUrl, // 选择图片返回的相对路径
  249. encoding: 'base64', // 编码格式
  250. success: res => { // 成功的回调
  251. uni.uploadFile({
  252. url: _this.$setting.BASE_URL + '/v1/user/uploadFile',
  253. // filePath: 'data:image/png;base64,' + res.data,
  254. filePath: detail.avatarUrl,
  255. name: 'file',
  256. success({
  257. data
  258. }) {
  259. const res = JSON.parse(data)
  260. const {
  261. url
  262. } = res.data
  263. _this.modal.avatar = url
  264. console.log('-->data', _this.modal.avatar)
  265. }
  266. })
  267. // this.modal.avatar = detail.avatarUrl
  268. // console.log('data:image/png;base64,' + res.data)
  269. }
  270. })
  271. },
  272. handleChangeNickname(res) {
  273. this.modal.nickname = res.detail.value
  274. },
  275. //获取当前页面路径
  276. getPageUrl() {
  277. const pages = getCurrentPages();
  278. console.log(pages, '--------->pages')
  279. if (pages.length == 1) {
  280. const currentPage = pages[0];
  281. let pageUrl = `/${currentPage.route}`;
  282. return pageUrl
  283. console.log('当前页面url:', pageUrl);
  284. } else {
  285. const currentPage = pages[pages.length - 1];
  286. let pageUrl = `/${currentPage.route}`;
  287. return pageUrl
  288. console.log('当前页面url:', pageUrl);
  289. }
  290. // pageUrl = this.pageUrl + '?id=' + this.detailID;
  291. },
  292. //登录
  293. getCode() {
  294. return new Promise((resolve, reject) => {
  295. uni.getUserInfo({
  296. success: loginRes => {
  297. this.data.encryptData = loginRes.encryptedData,
  298. this.data.iv = loginRes.iv
  299. resolve(this.data)
  300. }
  301. })
  302. })
  303. },
  304. //获取微信登录的code码
  305. getmsg() {
  306. if (this.isLoginOff) {
  307. uni.switchTab({
  308. url: '/pages/my/my'
  309. })
  310. } else {
  311. uni.login({
  312. provider: uni.$u.platform,
  313. success: res => {
  314. this.getCode().then((data) => {
  315. const params = {
  316. code: res.code,
  317. iv: data.iv,
  318. encryptData: data.encryptData
  319. }
  320. console.log(params);
  321. this.$api.my.myLogin(params).then(res => {
  322. if(res.code == 0){
  323. let {
  324. token
  325. } = res.data
  326. this.handleGetWechatUserInfo()
  327. // this.handleConfirmWechatUserInfo()
  328. this.$store.dispatch('user/token', token)
  329. }else{
  330. uni.showToast({
  331. icon:'none',
  332. title:res.msg
  333. })
  334. }
  335. })
  336. })
  337. }
  338. })
  339. }
  340. },
  341. }
  342. }
  343. </script>
  344. <style lang="scss" scoped>
  345. $pageColor:#F9F9F9;
  346. $bgColor:#FFFFFF;
  347. .youyue {
  348. height: 100%;
  349. background: $bgColor;
  350. padding: 0rpx 30rpx 140rpx 30rpx;
  351. position: relative;
  352. }
  353. .userinfo {
  354. position: absolute;
  355. top: 38rpx;
  356. left: 200rpx;
  357. .unlogin {
  358. width: 220rpx;
  359. font-size: 44rpx;
  360. font-family: PingFang-SC-Heavy, PingFang-SC;
  361. font-weight: 500;
  362. color: #FFFFFF;
  363. display: block;
  364. margin-top: 20rpx;
  365. }
  366. .username {
  367. width: 184rpx;
  368. height: 44rpx;
  369. font-size: 44rpx;
  370. font-family: PingFang-SC-Heavy, PingFang-SC;
  371. font-weight: 500;
  372. color: #FFFFFF;
  373. line-height: 44rpx;
  374. display: block;
  375. margin-bottom: 24rpx;
  376. }
  377. .userId {
  378. font-size: 32rpx;
  379. font-family: PingFang-SC-Medium, PingFang-SC;
  380. font-weight: 400;
  381. color: #FFFFFF;
  382. line-height: 32rpx;
  383. }
  384. }
  385. .nav {
  386. position: absolute;
  387. top: 0rpx;
  388. left: 0rpx;
  389. image {
  390. width: 750rpx;
  391. height: 142rpx;
  392. }
  393. }
  394. .title {
  395. width: 400rpx;
  396. height: 120rpx;
  397. font-size: 44rpx;
  398. font-family: PingFang-SC-Bold, PingFang-SC;
  399. font-weight: bold;
  400. color: #333333;
  401. line-height: 60rpx;
  402. margin-bottom: 64rpx;
  403. }
  404. .detail {
  405. width: 690rpx;
  406. height: 220rpx;
  407. margin-bottom: 64rpx;
  408. text {
  409. font-size: 32rpx;
  410. font-family: PingFang-SC-Medium, PingFang-SC;
  411. font-weight: 500;
  412. color: #333333;
  413. }
  414. }
  415. .item {
  416. margin: 40rpx 0;
  417. .itemtitle {
  418. font-size: 32rpx;
  419. font-family: PingFang-SC-Bold, PingFang-SC;
  420. font-weight: bold;
  421. color: #333333;
  422. }
  423. }
  424. .itemLast {
  425. width: 690rpx;
  426. font-size: 24rpx;
  427. font-family: PingFang-SC-Medium, PingFang-SC;
  428. font-weight: 500;
  429. color: #333333;
  430. margin-bottom: 64rpx;
  431. }
  432. .btn {
  433. width: 688rpx;
  434. height: 92rpx;
  435. background: linear-gradient(270deg, #FF6200 0%, #FF9342 100%);
  436. display: flex;
  437. align-items: center;
  438. justify-content: center;
  439. border-radius: 12rpx;
  440. text {
  441. font-size: 30rpx;
  442. font-family: PingFang-SC-Bold, PingFang-SC;
  443. font-weight: bold;
  444. color: #FFFFFF;
  445. }
  446. }
  447. .logintitle {
  448. height: 40rpx;
  449. width: 690rpx;
  450. margin-top: 64rpx;
  451. margin-bottom: 64rpx;
  452. display: flex;
  453. align-items: center;
  454. justify-content: space-between;
  455. .line {
  456. width: 240rpx;
  457. height: 2rpx;
  458. background: #EDEDED;
  459. border-radius: 1rpx;
  460. }
  461. .logintype {
  462. position: relative;
  463. top: -8rpx;
  464. text {
  465. font-size: 28rpx;
  466. font-family: PingFang-SC-Medium, PingFang-SC;
  467. font-weight: 500;
  468. color: #333333;
  469. }
  470. }
  471. }
  472. .typebtn {
  473. display: flex;
  474. align-items: center;
  475. justify-content: space-around;
  476. .item {
  477. width: 140rpx;
  478. height: 156rpx;
  479. display: flex;
  480. flex-direction: column;
  481. align-items: center;
  482. justify-content: center;
  483. image {
  484. width: 104rpx;
  485. height: 104rpx;
  486. margin-bottom: 12rpx;
  487. }
  488. text {
  489. display: block;
  490. font-size: 28rpx;
  491. font-family: PingFang-SC-Medium, PingFang-SC;
  492. font-weight: 500;
  493. color: #666666;
  494. }
  495. }
  496. }
  497. .boxitem {
  498. border-top: #F0F0F0 2rpx solid;
  499. border-bottom: #F0F0F0 2rpx solid;
  500. padding: 40rpx 0;
  501. position: relative;
  502. image {
  503. top: 35%;
  504. right: 0rpx;
  505. width: 96rpx;
  506. height: 96rpx;
  507. position: absolute;
  508. }
  509. .boxitemtitle {
  510. font-size: 32rpx;
  511. font-family: PingFang-SC-Bold, PingFang-SC;
  512. font-weight: bold;
  513. color: #333333;
  514. }
  515. .boxitemcontent {
  516. margin-top: 24rpx;
  517. width: 512rpx;
  518. display: block;
  519. font-size: 28rpx;
  520. font-family: PingFang-SC-Medium, PingFang-SC;
  521. font-weight: 500;
  522. color: #333333;
  523. }
  524. }
  525. //登录弹框
  526. .popup-login {
  527. width: 100%;
  528. height: 706rpx;
  529. background: #FFFFFF;
  530. box-shadow: 0rpx -10rpx 32rpx 0px rgba(0, 0, 0, 0.04);
  531. border-radius: 16rpx 16rpx 0px 0px;
  532. padding: 40rpx 64rpx 92rpx;
  533. .popup-login-top {
  534. display: flex;
  535. align-items: center;
  536. justify-content: flex-start;
  537. font-size: 30rpx;
  538. font-weight: bold;
  539. color: #000000;
  540. }
  541. .popup-login-main {
  542. width: 100%;
  543. display: flex;
  544. align-items: center;
  545. justify-content: center;
  546. margin-top: 62rpx;
  547. .avatar {
  548. width: 176rpx;
  549. height: 176rpx;
  550. border-radius: 50%;
  551. border: 0;
  552. background: transparent;
  553. &::after {
  554. border: none;
  555. }
  556. .user-avatar {
  557. object-fit: cover;
  558. object-position: center;
  559. }
  560. }
  561. }
  562. .popup-login-ipt {
  563. width: 100%;
  564. height: 88rpx;
  565. background: #F6F6F6;
  566. border-radius: 44rpx;
  567. display: flex;
  568. align-items: center;
  569. justify-content: center;
  570. margin-top: 48rpx;
  571. .avatar {
  572. width: 100%;
  573. height: 100%;
  574. text-align: center;
  575. font-size: 28rpx;
  576. font-weight: bold;
  577. color: #999999;
  578. }
  579. }
  580. .popup-login-btn {
  581. width: 100%;
  582. height: 88rpx;
  583. background: #1AAC1B;
  584. border-radius: 38rpx;
  585. display: flex;
  586. align-items: center;
  587. justify-content: center;
  588. margin-top: 32rpx;
  589. .confirm {
  590. border: 0;
  591. background: transparent;
  592. font-size: 28rpx;
  593. font-weight: bold;
  594. color: #FFFFFF;
  595. &::after {
  596. border: none;
  597. }
  598. }
  599. }
  600. .popup-login-text {
  601. display: flex;
  602. align-items: center;
  603. justify-content: center;
  604. margin-top: 32rpx;
  605. font-weight: bold;
  606. color: #999999;
  607. font-size: 22rpx;
  608. }
  609. }
  610. </style>