my.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <view class="ezy-my-page">
  3. <view class="icon-title-navBar-box my-title-navBar-box">
  4. <view class="nav-bar-title"></view>
  5. </view>
  6. <view class="my-page-box">
  7. <view class="my-head-box">
  8. <icon class="head-img-box" :style="{backgroundImage: 'url(' + myInfoData.icon + ')'}"></icon>
  9. <view class="head-content-box">
  10. <text>{{myInfoData.nickName}}</text>
  11. <!-- <view class="ezy-jf-box" v-if="loginFlag">
  12. <icon class="jf-icon"></icon>
  13. <text class="jf-text">{{myInfoData.credit}}</text>
  14. </view> -->
  15. </view>
  16. </view>
  17. <!-- 手机banner图 -->
  18. <swiper class="my-hyqy-swiper ezy-hidden-pad" circular :indicator-dots="hyqyData.indicatorDots" :autoplay="hyqyData.autoplay"
  19. :interval="hyqyData.interval" :duration="hyqyData.duration" indicator-color="#5195d3"
  20. indicator-active-color="#83d9ff" v-if="bannerArr">
  21. <!-- 1.数学 2.英语-->
  22. <swiper-item v-for="(item, index) in bannerArr" :key="index" class="hyqy-box" @click="hyqyBtn(item)">
  23. <img :src="item.addCover" class="my-banner-img" />
  24. </swiper-item>
  25. </swiper>
  26. <!-- padbanner图 -->
  27. <swiper class="my-hyqy-swiper ezy-hidden-phone" circular :indicator-dots="hyqyData.indicatorDots" :autoplay="hyqyData.autoplay"
  28. :interval="hyqyData.interval" :duration="hyqyData.duration" indicator-color="#5195d3"
  29. indicator-active-color="#83d9ff" v-if="bannerArr">
  30. <!-- 1.数学 2.英语-->
  31. <swiper-item v-for="(item, index) in bannerPadArr" :key="index" class="hyqy-box" @click="hyqyBtn(item)">
  32. <img :src="item.addCover" class="my-banner-img" />
  33. </swiper-item>
  34. </swiper>
  35. <!-- <view class="my-banner-img"></view> -->
  36. <!-- 设置 -->
  37. <view class="my-list-box">
  38. <view class="list-item" @click="shangcheng">
  39. <icon class="list-icon sc-icon"></icon>
  40. <text>商城</text>
  41. </view>
  42. <view class="list-item" @click="ddBtn">
  43. <icon class="list-icon dd-icon"></icon>
  44. <text>订单</text>
  45. </view>
  46. <view v-if="appleCode=='true'&&currentPlatform=='ios' || currentPlatform=='android'" class="list-item"
  47. @click="duihuamaDuihuan">
  48. <icon class="list-icon dhm-icon"></icon>
  49. <text>兑换码</text>
  50. </view>
  51. <view class="list-item" v-if="isShowBindPhone" @click="bangPhone">
  52. <icon class="list-icon bdsjh-icon"></icon>
  53. <text>绑定手机号</text>
  54. </view>
  55. <view class="list-item" @click="yingyongshezhi">
  56. <icon class="list-icon yysz-icon"></icon>
  57. <text>应用设置</text>
  58. </view>
  59. </view>
  60. </view>
  61. <goLogin ref="loginRef" @success="handleSuccess"></goLogin>
  62. <tipMiddleDialog ref="goLoRef" @confirm-btn="btntxt" :content="tishiTxt" qrBtnName="去登录"></tipMiddleDialog>
  63. <!-- 底部 -->
  64. <custom-tab-bar :show="true" :current-index="currentTabIndex" />
  65. </view>
  66. </template>
  67. <script setup>
  68. import cacheManager from '@/utils/cacheManager';
  69. import {
  70. myInfo,
  71. zhuxiao,
  72. duihuanmaCode,
  73. myCardList,
  74. commonCardList
  75. } from '@/api/my.js'
  76. import CustomTabBar from '@/components/custom-tabbar/index.vue';
  77. import goLogin from "@/components/goLogin/goLogin.vue"
  78. import tipMiddleDialog from '@/components/dialog/tipMiddleDialog.vue';
  79. import {
  80. onLoad,
  81. onShow
  82. } from '@dcloudio/uni-app';
  83. import {
  84. reactive,
  85. ref
  86. } from "vue";
  87. import {
  88. getUserIsYouke,
  89. toast
  90. } from "../../utils/common";
  91. let appleCode = ref(null)
  92. let currentPlatform = ref(null);
  93. let authInfo = ref(null);
  94. let loginRef = ref(null);
  95. let currentTabIndex = ref(3)
  96. let isShowBindPhone = ref(false);
  97. let myInfoData = reactive({
  98. userImg: '',
  99. userName: '',
  100. credit: '',
  101. vipFlag: '',
  102. nickName: '',
  103. icon: '',
  104. });
  105. let pageFrom = ref(null)
  106. const goLoRef = ref(null)
  107. let tishiTxt = ref('您现在是游客身份,请先登录再进行兑换操作!')
  108. // banner
  109. let hyqyData = reactive({
  110. indicatorDots: true,
  111. autoplay: true,
  112. interval: 10000,
  113. duration: 500
  114. });
  115. const bannerArr = ref([
  116. { addCover: 'static/images/phone/my/my-banner1.png' }, // 替换为实际图片路径
  117. { addCover: 'static/images/phone/my/my-banner2.png' } // 替换为实际图片路径
  118. ]);
  119. const bannerPadArr = ref([
  120. { addCover: 'static/images/pad/my/my-banner1.png' }, // 替换为实际图片路径
  121. { addCover: 'static/images/pad/my/my-banner2.png' } // 替换为实际图片路径
  122. ]);
  123. onShow(() => {
  124. console.log('pageFrom.value', pageFrom.value);
  125. currentTabIndex.value = 3
  126. if (pageFrom.value === 'myInfo') {
  127. getMyInfo();
  128. }
  129. if (getUserIsYouke()) {
  130. isShowBindPhone.value = true
  131. } else {
  132. isShowBindPhone.value = false
  133. }
  134. })
  135. function btntxt() {
  136. loginRef.value.showDl()
  137. }
  138. /***************** 测试 ******************/
  139. const testRef = ref(null)
  140. function handleTest() {
  141. testRef.value.showPopup(7)
  142. }
  143. /***************** 测试 ******************/
  144. function bangPhone() {
  145. pageFrom.value = 'myInfo'
  146. uni.navigateTo({
  147. url: '/pages/bindPhone/bindPhone?from=my'
  148. })
  149. }
  150. // 获取用户数据
  151. function getMyInfo() {
  152. return myInfo({}).then(res => {
  153. console.log('res', res);
  154. myInfoData.userName = res.data.userName;
  155. myInfoData.nickName = res.data.nickName;
  156. pageFrom.value = ''
  157. appleCode.value = res.data.appleCode.toString()
  158. myInfoData.nickName = res.data.nickName;
  159. if (res.data.icon) {
  160. myInfoData.icon = res.data.icon;
  161. } else {
  162. getUserImg()
  163. }
  164. })
  165. }
  166. // 获取用户头像
  167. function getUserImg() {
  168. myInfoData.icon = 'static/images/common/my/head-img1.png'
  169. }
  170. function yingyongshezhi() {
  171. pageFrom.value = 'myInfo'
  172. uni.navigateTo({
  173. url: '/pages/chanpinMy/myInfo'
  174. })
  175. }
  176. function ddBtn() {
  177. uni.navigateTo({
  178. url: '/pages/chanpinMy/order'
  179. })
  180. }
  181. function duihuamaDuihuan() {
  182. // 兑换码兑换策略
  183. if (getUserIsYouke()) {
  184. // 非登录 -- 登录
  185. goLoRef.value.handleShow();
  186. } else {
  187. // 已登录
  188. uni.navigateTo({
  189. url: '/pages/chanpinMy/duihuanma'
  190. })
  191. }
  192. }
  193. function handleSuccess(authInfo) {
  194. // 登录成功更改用户名
  195. // myInfoData.userName = authInfo.userName;
  196. getMyInfo().then(() => {
  197. // 前往兑换码
  198. uni.navigateTo({
  199. url: '/pages/chanpinMy/duihuanma'
  200. })
  201. });
  202. }
  203. onLoad((options) => {
  204. uni.hideTabBar()
  205. getAuthData();
  206. getMyInfo();
  207. isIOSorAndroid()
  208. })
  209. function isIOSorAndroid() {
  210. const systemInfo = uni.getSystemInfoSync();
  211. if (systemInfo.platform == 'ios') {
  212. currentPlatform.value = 'ios'
  213. } else {
  214. currentPlatform.value = 'android'
  215. }
  216. }
  217. function getAuthData() {
  218. authInfo.value = cacheManager.get('auth');
  219. }
  220. // 商城
  221. function shangcheng() {
  222. uni.navigateTo({
  223. url: '/pages/chanpinShop/index'
  224. })
  225. }
  226. </script>