index.vue 12 KB

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