index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. <template>
  2. <page-layout class="user-index">
  3. <nav-bar title="个人中心" @init="onInitNavbar"></nav-bar>
  4. <u-scroll-view :tabbar-conflict="true">
  5. <view class="main-container">
  6. <view class="user-info" @click="navigateToAdLink('/pages/user/info')">
  7. <view class="user-avator">
  8. <image v-if="isLoginState && avatar" :src="avatar"/>
  9. <van-icon v-else class="icon" name="user"/>
  10. </view>
  11. <view class="user-title">
  12. <view class="user-name">
  13. <template v-if="isLoginState">{{ nickName || phone }}</template>
  14. <template v-else>请登录/注册</template>
  15. </view>
  16. <view v-if="isLoginState && nickName" class="user-phone">手机号:{{ phone }}</view>
  17. </view>
  18. <view class="user-option" @click.stop="navigateToAdLink('/pages/user/setting')">
  19. <view class="iconfont icon-setting"></view>
  20. <view>设置</view>
  21. </view>
  22. </view>
  23. <view class="user-grid-menu">
  24. <view hover-class="active" @click="navigateToAdLink('/pages/user/like')">
  25. <view class="iconfont icon-heart1"></view>
  26. <view>点赞</view>
  27. </view>
  28. <view hover-class="active" @click="navigateToAdLink('/pages/user/favorites')">
  29. <view class="iconfont icon-Favourites-Add-Large"></view>
  30. <view>收藏</view>
  31. </view>
  32. <view hover-class="active" @click="navigateToAdLink('/pages/user/vote')">
  33. <view class="iconfont icon-xiaochengxu-toupiaoicon"></view>
  34. <view>投票</view>
  35. </view>
  36. <view hover-class="active" @click="navigateTo('https://pc.global-eservice.com/h5/?lang=cn&channel=xcx#/')">
  37. <view class="iconfont icon-bishi"></view>
  38. <view>参观登记</view>
  39. </view>
  40. </view>
  41. <view class="user-list-item">
  42. <!-- <van-cell-group>
  43. <van-cell title="我的奖品" icon="iconfont icon-jiangpin" is-link @click="navigateToAdLink('/pages/disclaimer/privacy')">
  44. </van-cell>
  45. <van-cell title="奖品核销" icon="iconfont icon-saoyisao_1" is-link @click="navigateToAdLink('/pages/disclaimer/privacy')">
  46. </van-cell>
  47. <van-cell title="隐私政策" is-link @click="navigateToAdLink('/pages/disclaimer/privacy')">
  48. </van-cell>
  49. <van-cell title="法律信息" is-link @click="navigateToAdLink('/pages/disclaimer/legalNotice')">
  50. </van-cell>
  51. </van-cell-group>-->
  52. <view class="user-item" @click="navigateToAdLink('/pages/user/award')">
  53. <view class="iconfont icon-jiangpin"></view>
  54. <text class="user-item-text">我的奖品</text>
  55. <view class="iconfont icon-Left-1"></view>
  56. </view>
  57. <view class="user-item" @click="scanCodeEvent()" v-if="is_super">
  58. <view class="iconfont icon-saoyisao_1"></view>
  59. <text class="user-item-text">奖品核销</text>
  60. <view class="iconfont icon-Left-1"></view>
  61. </view>
  62. <view class="user-item" @click="navigateToAdLink('/pages/disclaimer/privacy')">
  63. <text class="user-item-text">隐私政策</text>
  64. <view class="iconfont icon-Left-1"></view>
  65. </view>
  66. <view class="user-item" @click="navigateToAdLink('/pages/disclaimer/legalNotice')">
  67. <text class="user-item-text">法律信息</text>
  68. <view class="iconfont icon-Left-1"></view>
  69. </view>
  70. </view>
  71. <van-overlay :show="prizeShow">
  72. <view class="overlay_wrapper">
  73. <view class="overlay_body">
  74. <view class="overlay_title">
  75. <view class="iconfont icon-Check"></view> 核销奖品成功
  76. </view>
  77. <view class="overlay_image">
  78. <image mode="widthFix" :src="decodeInfo.picture_url"></image>
  79. </view>
  80. <view class="overlay_name">
  81. 奖品:{{ decodeInfo.name }}
  82. </view>
  83. <view class="overlay_desc">
  84. 打卡路线
  85. <text>{{ decodeInfo.route_count }}</text>
  86. </view>
  87. </view>
  88. <view class="iconfont icon-Cancel-copy" @click="hideOverlay"></view>
  89. </view>
  90. </van-overlay>
  91. <view class="ad-space" v-if="adInfo && adInfo.ad_file" @tap="navigateToAdLink(adInfo.ad_link)">
  92. <image :src="adInfo.ad_file" mode="widthFix"/>
  93. </view>
  94. </view>
  95. </u-scroll-view>
  96. </page-layout>
  97. </template>
  98. <script>
  99. import NavBar from '@/components/layout/nav-bar'
  100. import UScrollView from '@/components/common/u-scroll-view'
  101. import VanCell from '@/wxcomponents/vant/cell/index'
  102. import VanOverlay from '@/wxcomponents/vant/overlay/index'
  103. import VanCellGroup from '@/wxcomponents/vant/cell-group/index'
  104. import PageLayout from "@/components/layout/page-layout";
  105. import {getAdInfo} from '@/api'
  106. import store from "@/store";
  107. import {qrcodeDecode} from "@/api/checkIn";
  108. import Toast from "@/wxcomponents/vant/toast/toast";
  109. import Dialog from "@/wxcomponents/vant/dialog/dialog";
  110. export default {
  111. options: {
  112. styleIsolation: 'shared'
  113. },
  114. components: {
  115. PageLayout,
  116. NavBar,
  117. UScrollView,
  118. VanCell,
  119. VanCellGroup,
  120. VanOverlay
  121. },
  122. computed: {
  123. isLoginState() {
  124. return this.$store.getters.user !== null
  125. },
  126. avatar() {
  127. const user = this.$store.getters.user
  128. if (user) {
  129. return user.avatar
  130. } else {
  131. return ''
  132. }
  133. },
  134. nickName() {
  135. const user = this.$store.getters.user
  136. if (user) {
  137. return user.nick_name
  138. } else {
  139. return ''
  140. }
  141. },
  142. phone() {
  143. const user = this.$store.getters.user
  144. if (user) {
  145. return user.phone
  146. } else {
  147. return ''
  148. }
  149. },
  150. is_super() {
  151. const user = this.$store.getters.user
  152. if (user) {
  153. return user.is_super === 2
  154. } else {
  155. return ''
  156. }
  157. }
  158. },
  159. data() {
  160. return {
  161. prizeShow: false,
  162. decodeInfo: {},
  163. adInfo: {
  164. ad_file: ''
  165. }
  166. }
  167. },
  168. created() {
  169. this.getAdData()
  170. },
  171. methods: {
  172. hideOverlay() {
  173. this.prizeShow = false
  174. this.decodeInfo = {}
  175. },
  176. getSceneParamsEvent(finalStr) {
  177. const {a, t} = finalStr.split('&').reduce((obj, pair) => {
  178. const [key, value] = pair.split('=');
  179. obj[key] = Number(value) || null; // 自动转数字
  180. return obj;
  181. }, {});
  182. return {a: a, t: t}
  183. },
  184. scanCodeEvent() {
  185. let that = this
  186. wx.scanCode({
  187. onlyFromCamera: true,
  188. success (res) {
  189. if (!res.path) {
  190. Dialog.alert({
  191. message: '该二维码不能进行核销',
  192. }).then(() => {
  193. });
  194. return false
  195. }
  196. let scene = res.path.split('scene=')
  197. if (scene && scene[1]) {
  198. const decoded = decodeURIComponent(scene[1])
  199. .replace(/\%/g, '%25'); // 防止二次解码丢失%
  200. if (decoded.indexOf('&t=') > -1) {
  201. let type = decoded.split('&t=')
  202. console.log(type)
  203. if (type[1] === "0") {
  204. Dialog.alert({
  205. message: '该二维码不能进行核销',
  206. }).then(() => {
  207. });
  208. }
  209. if (type[1] === "1") {
  210. that.qrcodeDecodeEvent(decoded,()=>{
  211. that.prizeShow = true
  212. })
  213. }
  214. } else {
  215. Dialog.alert({
  216. message: '该二维码不能进行核销',
  217. }).then(() => {
  218. });
  219. }
  220. } else {
  221. Dialog.alert({
  222. message: '该二维码不能进行核销',
  223. }).then(() => {
  224. });
  225. }
  226. }
  227. })
  228. },
  229. qrcodeDecodeEvent(scene, callback) {
  230. qrcodeDecode({scene: scene}).then(res => {
  231. if (res.code === 0) {
  232. Toast.success('核销奖品成功');
  233. this.decodeInfo = res.data
  234. if (callback) {
  235. callback()
  236. }
  237. }
  238. })
  239. },
  240. getAdData() {
  241. getAdInfo({
  242. number: "UserCenter001"
  243. }).then(res => {
  244. this.adInfo = res.data[0]
  245. })
  246. },
  247. navigateToAdLink(href) {
  248. if (!store.getters.user) {
  249. this.navigateTo('/pages/user/login?redirect=' + encodeURIComponent(href))
  250. return false
  251. } else {
  252. this.navigateTo(href)
  253. }
  254. }
  255. }
  256. }
  257. </script>
  258. <style lang="scss">
  259. .overlay_wrapper {
  260. display: flex;
  261. justify-content: center;
  262. align-items: center;
  263. width: 100%;
  264. height: 100%;
  265. position: relative;
  266. .overlay_body {
  267. background-color: #ffffff;
  268. padding: 40rpx;
  269. border-radius: 20rpx;
  270. display: flex;
  271. flex-direction: column;
  272. align-items: center;
  273. justify-content: center;
  274. grid-gap: 24rpx;
  275. width: 60%;
  276. font-size: 30rpx;
  277. }
  278. .overlay_title {
  279. font-size: 36rpx;
  280. display: flex;
  281. align-items: center;
  282. grid-gap: 10rpx;
  283. .iconfont {
  284. color: green;
  285. font-size: 50rpx;
  286. }
  287. }
  288. .overlay_desc {
  289. text {
  290. color: #E57519;
  291. }
  292. }
  293. .overlay_image {
  294. border: 1rpx solid #eeeeee;
  295. padding: 40rpx;
  296. image {
  297. aspect-ratio: 1;
  298. width: 220rpx;
  299. height: 220rpx;
  300. }
  301. }
  302. .overlay_name {
  303. }
  304. & > .iconfont {
  305. position: absolute;
  306. right: 30rpx;
  307. top: 250rpx;
  308. color: #ffffff;
  309. font-size: 40rpx;
  310. }
  311. }
  312. .user-info {
  313. display: flex;
  314. align-items: center;
  315. .user-title {
  316. flex: 1;
  317. min-width: 1px;
  318. }
  319. .user-option {
  320. display: flex;
  321. align-items: center;
  322. grid-gap: 6px;
  323. font-size: 28rpx;
  324. padding-left: 30rpx;
  325. height: 100rpx;
  326. padding-right: 20rpx;
  327. .iconfont {
  328. font-size: 36rpx;
  329. }
  330. }
  331. .user-avator {
  332. @include display-flex-center;
  333. width: 111rpx;
  334. height: 111rpx;
  335. border-radius: 50%;
  336. overflow: hidden;
  337. margin-right: 23rpx;
  338. background-color: $buttonPrimaryColor;
  339. .icon {
  340. color: #ffffff;
  341. opacity: 0.67;
  342. font-size: 70rpx;
  343. }
  344. }
  345. .user-name {
  346. font-size: 30rpx;
  347. color: #333333;
  348. //height: 100rpx;
  349. }
  350. .user-phone {
  351. font-size: $fontSize3;
  352. color: #7d7d7d;
  353. }
  354. }
  355. .user-grid-menu {
  356. display: grid;
  357. grid-template-columns: repeat(4, 1fr);
  358. height: 192rpx;
  359. margin-top: 60rpx;
  360. background-color: #FFFFFF;
  361. & > view {
  362. @include display-flex-center;
  363. flex-direction: column;
  364. font-size: $fontSize3;
  365. color: #333333;
  366. cursor: pointer;
  367. &.active {
  368. background-color: rgba(0, 0, 0, 0.05)
  369. }
  370. }
  371. .iconfont {
  372. margin-bottom: 19rpx;
  373. font-size: 44rpx;
  374. }
  375. .icon-Heart,
  376. .icon-xiaochengxu-toupiaoicon {
  377. font-size: 48rpx;
  378. }
  379. }
  380. .user-list-item {
  381. margin-top: 23rpx;
  382. display: flex;
  383. flex-direction: column;
  384. grid-gap: 21rpx;
  385. color: #181818;
  386. .user-item {
  387. display: flex;
  388. grid-gap: 14rpx;
  389. align-items: center;
  390. line-height: 1;
  391. padding: 40rpx;
  392. background-color: #ffffff;
  393. border-radius: 10rpx;
  394. .iconfont {
  395. font-size: 48rpx;
  396. }
  397. .icon-Left-1 {
  398. color: #4d4d4d;
  399. font-size: 42rpx;
  400. }
  401. .user-item-text {
  402. font-size: $fontSize4;
  403. flex: 1;
  404. min-width: 1px;
  405. }
  406. }
  407. /* .van-cell {
  408. --cell-horizontal-padding: 58rpx;
  409. }*/
  410. }
  411. .ad-space {
  412. width: 100%;
  413. margin-top: 23rpx;
  414. }
  415. </style>