index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  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. export default {
  110. options: {
  111. styleIsolation: 'shared'
  112. },
  113. components: {
  114. PageLayout,
  115. NavBar,
  116. UScrollView,
  117. VanCell,
  118. VanCellGroup,
  119. VanOverlay
  120. },
  121. computed: {
  122. isLoginState() {
  123. return this.$store.getters.user !== null
  124. },
  125. avatar() {
  126. const user = this.$store.getters.user
  127. if (user) {
  128. return user.avatar
  129. } else {
  130. return ''
  131. }
  132. },
  133. nickName() {
  134. const user = this.$store.getters.user
  135. if (user) {
  136. return user.nick_name
  137. } else {
  138. return ''
  139. }
  140. },
  141. phone() {
  142. const user = this.$store.getters.user
  143. if (user) {
  144. return user.phone
  145. } else {
  146. return ''
  147. }
  148. },
  149. is_super() {
  150. const user = this.$store.getters.user
  151. if (user) {
  152. return user.is_super === 2
  153. } else {
  154. return ''
  155. }
  156. }
  157. },
  158. data() {
  159. return {
  160. prizeShow: false,
  161. decodeInfo: {},
  162. adInfo: {
  163. ad_file: ''
  164. }
  165. }
  166. },
  167. created() {
  168. this.getAdData()
  169. },
  170. methods: {
  171. hideOverlay() {
  172. this.prizeShow = false
  173. this.decodeInfo = {}
  174. },
  175. getSceneParamsEvent(finalStr) {
  176. const {a, t} = finalStr.split('&').reduce((obj, pair) => {
  177. const [key, value] = pair.split('=');
  178. obj[key] = Number(value) || null; // 自动转数字
  179. return obj;
  180. }, {});
  181. return {a: a, t: t}
  182. },
  183. scanCodeEvent() {
  184. let that = this
  185. wx.scanCode({
  186. onlyFromCamera: true,
  187. success (res) {
  188. let scene = res.path.split('scene=')
  189. const decoded = decodeURIComponent(scene[1])
  190. .replace(/\%/g, '%25'); // 防止二次解码丢失%
  191. const finalStr = decodeURIComponent(decoded);
  192. that.qrcodeDecodeEvent(finalStr,()=>{
  193. that.prizeShow = true
  194. })
  195. }
  196. })
  197. },
  198. qrcodeDecodeEvent(scene, callback) {
  199. qrcodeDecode({scene: scene}).then(res => {
  200. if (res.code === 0) {
  201. Toast.success('核销奖品成功');
  202. this.decodeInfo = res.data
  203. if (callback) {
  204. callback()
  205. }
  206. }
  207. })
  208. },
  209. getAdData() {
  210. getAdInfo({
  211. number: "UserCenter001"
  212. }).then(res => {
  213. this.adInfo = res.data[0]
  214. })
  215. },
  216. navigateToAdLink(href) {
  217. if (!store.getters.user) {
  218. this.navigateTo('/pages/user/login?redirect=' + encodeURIComponent(href))
  219. return false
  220. } else {
  221. this.navigateTo(href)
  222. }
  223. }
  224. }
  225. }
  226. </script>
  227. <style lang="scss">
  228. .overlay_wrapper {
  229. display: flex;
  230. justify-content: center;
  231. align-items: center;
  232. width: 100%;
  233. height: 100%;
  234. position: relative;
  235. .overlay_body {
  236. background-color: #ffffff;
  237. padding: 40rpx;
  238. border-radius: 20rpx;
  239. display: flex;
  240. flex-direction: column;
  241. align-items: center;
  242. justify-content: center;
  243. grid-gap: 24rpx;
  244. width: 60%;
  245. font-size: 30rpx;
  246. }
  247. .overlay_title {
  248. font-size: 36rpx;
  249. display: flex;
  250. align-items: center;
  251. grid-gap: 10rpx;
  252. .iconfont {
  253. color: green;
  254. font-size: 50rpx;
  255. }
  256. }
  257. .overlay_desc {
  258. text {
  259. color: #E57519;
  260. }
  261. }
  262. .overlay_image {
  263. border: 1rpx solid #eeeeee;
  264. padding: 40rpx;
  265. image {
  266. aspect-ratio: 1;
  267. width: 220rpx;
  268. height: 220rpx;
  269. }
  270. }
  271. .overlay_name {
  272. }
  273. & > .iconfont {
  274. position: absolute;
  275. right: 30rpx;
  276. top: 250rpx;
  277. color: #ffffff;
  278. font-size: 40rpx;
  279. }
  280. }
  281. .user-info {
  282. display: flex;
  283. align-items: center;
  284. .user-title {
  285. flex: 1;
  286. min-width: 1px;
  287. }
  288. .user-option {
  289. display: flex;
  290. align-items: center;
  291. grid-gap: 6px;
  292. font-size: 28rpx;
  293. padding-left: 30rpx;
  294. height: 100rpx;
  295. padding-right: 20rpx;
  296. .iconfont {
  297. font-size: 36rpx;
  298. }
  299. }
  300. .user-avator {
  301. @include display-flex-center;
  302. width: 111rpx;
  303. height: 111rpx;
  304. border-radius: 50%;
  305. overflow: hidden;
  306. margin-right: 23rpx;
  307. background-color: $buttonPrimaryColor;
  308. .icon {
  309. color: #ffffff;
  310. opacity: 0.67;
  311. font-size: 70rpx;
  312. }
  313. }
  314. .user-name {
  315. font-size: 30rpx;
  316. color: #333333;
  317. //height: 100rpx;
  318. }
  319. .user-phone {
  320. font-size: $fontSize3;
  321. color: #7d7d7d;
  322. }
  323. }
  324. .user-grid-menu {
  325. display: grid;
  326. grid-template-columns: repeat(4, 1fr);
  327. height: 192rpx;
  328. margin-top: 60rpx;
  329. background-color: #FFFFFF;
  330. & > view {
  331. @include display-flex-center;
  332. flex-direction: column;
  333. font-size: $fontSize3;
  334. color: #333333;
  335. cursor: pointer;
  336. &.active {
  337. background-color: rgba(0, 0, 0, 0.05)
  338. }
  339. }
  340. .iconfont {
  341. margin-bottom: 19rpx;
  342. font-size: 44rpx;
  343. }
  344. .icon-Heart,
  345. .icon-xiaochengxu-toupiaoicon {
  346. font-size: 48rpx;
  347. }
  348. }
  349. .user-list-item {
  350. margin-top: 23rpx;
  351. display: flex;
  352. flex-direction: column;
  353. grid-gap: 21rpx;
  354. color: #181818;
  355. .user-item {
  356. display: flex;
  357. grid-gap: 14rpx;
  358. align-items: center;
  359. line-height: 1;
  360. padding: 40rpx;
  361. background-color: #ffffff;
  362. border-radius: 10rpx;
  363. .iconfont {
  364. font-size: 48rpx;
  365. }
  366. .icon-Left-1 {
  367. color: #4d4d4d;
  368. font-size: 42rpx;
  369. }
  370. .user-item-text {
  371. font-size: $fontSize4;
  372. flex: 1;
  373. min-width: 1px;
  374. }
  375. }
  376. /* .van-cell {
  377. --cell-horizontal-padding: 58rpx;
  378. }*/
  379. }
  380. .ad-space {
  381. width: 100%;
  382. margin-top: 23rpx;
  383. }
  384. </style>