index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  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" v-if="isLoginState && (activityOff || is_super)" @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" v-show="decodeInfo.picture_url" :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 {getActivitySwitch, 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. name: '',
  164. route_count: '',
  165. picture_url: ''
  166. },
  167. activityOff: 0,
  168. adInfo: {
  169. ad_file: ''
  170. },
  171. }
  172. },
  173. created() {
  174. this.getAdData()
  175. this.getActivitySwitchEvent()
  176. },
  177. methods: {
  178. getActivitySwitchEvent() {
  179. getActivitySwitch().then(res=>{
  180. this.activityOff = res.data.data.activity
  181. })
  182. },
  183. hideOverlay() {
  184. this.prizeShow = false
  185. this.decodeInfo = {
  186. name: '',
  187. route_count: '',
  188. picture_url: ''
  189. }
  190. },
  191. getSceneParamsEvent(finalStr) {
  192. const {a, t} = finalStr.split('&').reduce((obj, pair) => {
  193. const [key, value] = pair.split('=');
  194. obj[key] = Number(value) || null; // 自动转数字
  195. return obj;
  196. }, {});
  197. return {a: a, t: t}
  198. },
  199. scanCodeEvent() {
  200. let that = this
  201. wx.scanCode({
  202. onlyFromCamera: true,
  203. success (res) {
  204. if (!res.path) {
  205. Dialog.alert({
  206. message: '该二维码不能进行核销',
  207. }).then(() => {
  208. });
  209. return false
  210. }
  211. let scene = res.path.split('scene=')
  212. if (scene && scene[1]) {
  213. const decoded = decodeURIComponent(scene[1])
  214. .replace(/\%/g, '%25'); // 防止二次解码丢失%
  215. if (decoded.indexOf('&t=') > -1) {
  216. let type = decoded.split('&t=')
  217. console.log(type)
  218. if (type[1] === "0") {
  219. Dialog.alert({
  220. message: '该二维码不能进行核销',
  221. }).then(() => {
  222. });
  223. }
  224. if (type[1] === "1") {
  225. that.qrcodeDecodeEvent(decoded,()=>{
  226. that.prizeShow = true
  227. })
  228. }
  229. } else {
  230. Dialog.alert({
  231. message: '该二维码不能进行核销',
  232. }).then(() => {
  233. });
  234. }
  235. } else {
  236. Dialog.alert({
  237. message: '该二维码不能进行核销',
  238. }).then(() => {
  239. });
  240. }
  241. }
  242. })
  243. },
  244. qrcodeDecodeEvent(scene, callback) {
  245. qrcodeDecode({scene: scene}).then(res => {
  246. if (res.code === 0) {
  247. Toast.success('核销奖品成功');
  248. this.decodeInfo = res.data
  249. if (callback) {
  250. callback()
  251. }
  252. }
  253. })
  254. },
  255. getAdData() {
  256. getAdInfo({
  257. number: "UserCenter001"
  258. }).then(res => {
  259. this.adInfo = res.data[0]
  260. })
  261. },
  262. navigateToAdLink(href) {
  263. if (!store.getters.user) {
  264. this.navigateTo('/pages/user/login?redirect=' + encodeURIComponent(href))
  265. return false
  266. } else {
  267. this.navigateTo(href)
  268. }
  269. }
  270. }
  271. }
  272. </script>
  273. <style lang="scss">
  274. .overlay_wrapper {
  275. display: flex;
  276. justify-content: center;
  277. align-items: center;
  278. width: 100%;
  279. height: 100%;
  280. position: relative;
  281. .overlay_body {
  282. background-color: #ffffff;
  283. padding: 40rpx;
  284. border-radius: 20rpx;
  285. display: flex;
  286. flex-direction: column;
  287. align-items: center;
  288. justify-content: center;
  289. grid-gap: 24rpx;
  290. width: 60%;
  291. font-size: 30rpx;
  292. }
  293. .overlay_title {
  294. font-size: 36rpx;
  295. display: flex;
  296. align-items: center;
  297. grid-gap: 10rpx;
  298. .iconfont {
  299. color: green;
  300. font-size: 50rpx;
  301. }
  302. }
  303. .overlay_desc {
  304. text {
  305. color: #E57519;
  306. }
  307. }
  308. .overlay_image {
  309. border: 1rpx solid #eeeeee;
  310. padding: 40rpx;
  311. image {
  312. aspect-ratio: 1;
  313. width: 220rpx;
  314. height: 220rpx;
  315. }
  316. }
  317. .overlay_name {
  318. }
  319. & > .iconfont {
  320. position: absolute;
  321. right: 30rpx;
  322. top: 250rpx;
  323. color: #ffffff;
  324. font-size: 40rpx;
  325. }
  326. }
  327. .user-info {
  328. display: flex;
  329. align-items: center;
  330. .user-title {
  331. flex: 1;
  332. min-width: 1px;
  333. }
  334. .user-option {
  335. display: flex;
  336. align-items: center;
  337. grid-gap: 6px;
  338. font-size: 28rpx;
  339. padding-left: 30rpx;
  340. height: 100rpx;
  341. padding-right: 20rpx;
  342. .iconfont {
  343. font-size: 36rpx;
  344. }
  345. }
  346. .user-avator {
  347. @include display-flex-center;
  348. width: 111rpx;
  349. height: 111rpx;
  350. border-radius: 50%;
  351. overflow: hidden;
  352. margin-right: 23rpx;
  353. background-color: $buttonPrimaryColor;
  354. .icon {
  355. color: #ffffff;
  356. opacity: 0.67;
  357. font-size: 70rpx;
  358. }
  359. }
  360. .user-name {
  361. font-size: 30rpx;
  362. color: #333333;
  363. //height: 100rpx;
  364. }
  365. .user-phone {
  366. font-size: $fontSize3;
  367. color: #7d7d7d;
  368. }
  369. }
  370. .user-grid-menu {
  371. display: grid;
  372. grid-template-columns: repeat(4, 1fr);
  373. height: 192rpx;
  374. margin-top: 60rpx;
  375. background-color: #FFFFFF;
  376. & > view {
  377. @include display-flex-center;
  378. flex-direction: column;
  379. font-size: $fontSize3;
  380. color: #333333;
  381. cursor: pointer;
  382. &.active {
  383. background-color: rgba(0, 0, 0, 0.05)
  384. }
  385. }
  386. .iconfont {
  387. margin-bottom: 19rpx;
  388. font-size: 44rpx;
  389. }
  390. .icon-Heart,
  391. .icon-xiaochengxu-toupiaoicon {
  392. font-size: 48rpx;
  393. }
  394. }
  395. .user-list-item {
  396. margin-top: 23rpx;
  397. display: flex;
  398. flex-direction: column;
  399. grid-gap: 21rpx;
  400. color: #181818;
  401. .user-item {
  402. display: flex;
  403. grid-gap: 14rpx;
  404. align-items: center;
  405. line-height: 1;
  406. padding: 40rpx;
  407. background-color: #ffffff;
  408. border-radius: 10rpx;
  409. .iconfont {
  410. font-size: 48rpx;
  411. }
  412. .icon-Left-1 {
  413. color: #4d4d4d;
  414. font-size: 42rpx;
  415. }
  416. .user-item-text {
  417. font-size: $fontSize4;
  418. flex: 1;
  419. min-width: 1px;
  420. }
  421. }
  422. /* .van-cell {
  423. --cell-horizontal-padding: 58rpx;
  424. }*/
  425. }
  426. .ad-space {
  427. width: 100%;
  428. margin-top: 23rpx;
  429. }
  430. </style>