yingyongshezhi.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. <template>
  2. <view class="ezy-my-page">
  3. <view class="icon-title-navBar-box">
  4. <view @click="handleBack" class="nav-bar-icon"></view>
  5. <text class="nav-bar-title">关于我们</text>
  6. </view>
  7. <view class="my-head-box">
  8. <icon class="head-img-box" :style="{backgroundImage: 'url(' + myInfoData.userImg + ')'}"></icon>
  9. <view class="head-content-box">
  10. <text>昵称</text>
  11. <text>{{myInfoData.userName}}</text>
  12. </view>
  13. </view>
  14. <view class="my-list-box">
  15. <view class="list-row" @click="telClick">
  16. <icon class="list-icon tel-icon"></icon>
  17. <text>手机号码</text>
  18. </view>
  19. <view class="list-row" @click="aboutClick">
  20. <icon class="list-icon about-icon"></icon>
  21. <text>关于我们</text>
  22. </view>
  23. <view v-if="loginFlag" class="list-row" @click="yonghuzhuxiao">
  24. <icon class="list-icon zhuxiao-icon"></icon>
  25. <text>用户注销</text>
  26. </view>
  27. <view v-if="loginFlag" class="list-row" @click="yinsizhengce">
  28. <icon class="list-icon yszc-icon"></icon>
  29. <text>隐私政策</text>
  30. </view>
  31. <view class="list-row" @click="kefudianhua">
  32. <icon class="list-icon kfdh-icon"></icon>
  33. <text>客服与投诉</text>
  34. <text>4001750778</text>
  35. </view>
  36. <view class="list-row" @click="exitLogin">
  37. <icon class="list-icon login-out-icon"></icon>
  38. <text>退出登录</text>
  39. </view>
  40. </view>
  41. <CustomTabBar :levelId="levelId" :currentTabNumber="3" :typeId="typeId" :subjectId="subjectId"
  42. :tipFlag="tipFlag">
  43. </CustomTabBar>
  44. <tip-small-dialog ref="exitDialogRef" @confirm-btn="exitBtn" :content="tipContent"></tip-small-dialog>
  45. <tip-big-dialog ref="youkeDialogRef" @confirm-btn="ykConfirm" :imgShow="true"></tip-big-dialog>
  46. <tip-small-dialog ref="zhuxiaoDialogRef" @confirm-btn="zhuxiaoBtn" :content="zhuxiaoContent"></tip-small-dialog>
  47. <duihuanmaDialog ref="duihuanmaDialogRef" @confirm-btn="duihuanmaBtn" title="兑换"></duihuanmaDialog>
  48. <tel-dialog @telClose="telClose" @bindBtn="bindBtn" v-if="telDialogFlag"></tel-dialog>
  49. <agree-content-dialog ref="agreeContentDialogRef" :agreeType="agreeType"></agree-content-dialog>
  50. <tip-small-dialog ref="kefuDialogRef" :title="kefuTitle" @confirm-btn="kefuBtn" :content="kefuContent"
  51. class="kefu-dialog"></tip-small-dialog>
  52. </view>
  53. </template>
  54. <script setup>
  55. import agreeContentDialog from '@/pages/login/agreeContentDialog.vue';
  56. import {
  57. toast,
  58. getUserIdentity
  59. } from "@/utils/common";
  60. import cacheManager from '@/utils/cacheManager.js';
  61. import {
  62. logout
  63. } from '@/api/login.js'
  64. import {
  65. myInfo,
  66. zhuxiao,
  67. duihuanmaCode,
  68. myCardList,
  69. commonCardList
  70. } from '@/api/my.js'
  71. import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
  72. import {
  73. getCurrentInstance
  74. } from 'vue';
  75. import {
  76. onLoad
  77. } from '@dcloudio/uni-app';
  78. import {
  79. reactive,
  80. ref
  81. } from "vue";
  82. import tipSmallDialog from '@/components/dialog/tipSmallDialog.vue';
  83. import duihuanmaDialog from '@/components/dialog/duihuanmaDialog.vue';
  84. import tipMiddleDialog from '@/components/dialog/tipMiddleDialog.vue';
  85. import tipBigDialog from '@/components/dialog/tipBigDialog.vue';
  86. import telDialog from './telDialog.vue'
  87. import {
  88. MESSAGE_VISITER_TO_LOGIN
  89. } from "@/utils/constant.js"
  90. import {
  91. onShow
  92. } from '@dcloudio/uni-app';
  93. onShow(() => {
  94. if (!cacheManager.get('auth')) {
  95. youkeFun();
  96. } else {
  97. // 非游客
  98. noYoukeFun();
  99. }
  100. })
  101. const agreeType = ref(null);
  102. const agreeContentDialogRef = ref(null);
  103. const subjectId = ref(null); //游客使用
  104. const levelId = ref(null); //游客使用
  105. const typeId = ref(null); //游客使用
  106. const tipFlag = ref(null); //游客使用
  107. const tipContent = '你确定要执行这个操作吗?';
  108. const zhuxiaoContent = '你确定要执行这个操作吗?';
  109. const duihuanmaContent = '你确定要执行这个操作吗?';
  110. let hyqyData = reactive({
  111. indicatorDots: true,
  112. autoplay: true,
  113. interval: 10000,
  114. duration: 500
  115. });
  116. let loginFlag = ref(false);
  117. let telDialogFlag = ref(false);
  118. let myInfoData = reactive({
  119. userImg: '',
  120. userName: '',
  121. credit: '',
  122. vipFlag: '',
  123. });
  124. let routerOpt = ref(false);
  125. let appleCode = ref(null);
  126. let currentPlatform = ref(null);
  127. const exitDialogRef = ref(null);
  128. const youkeDialogRef = ref(null);
  129. const zhuxiaoDialogRef = ref(null);
  130. const duihuanmaDialogRef = ref(null);
  131. const bannerArr = ref(null);
  132. const kefuDialogRef = ref(null);
  133. const kefuTitle = '提示';
  134. const kefuContent = '客服电话:17304117625';
  135. const exitLogin = () => {
  136. exitDialogRef.value.handleShow();
  137. }
  138. function handleBack() {
  139. uni.redirectTo({
  140. url: '/pages/my/index'
  141. })
  142. }
  143. // 退出按钮
  144. const exitBtn = () => {
  145. if (loginFlag.value) {
  146. logout().then(res => {
  147. toast('退出登录成功')
  148. cacheManager.clearAll();
  149. uni.reLaunch({
  150. url: '/pages/login/index'
  151. });
  152. }).catch(err => {
  153. toast('退出登录失败,请稍后重试')
  154. })
  155. } else {
  156. uni.reLaunch({
  157. url: '/pages/login/index'
  158. });
  159. }
  160. }
  161. const zhuxiaoBtn = () => {
  162. let req = {
  163. }
  164. zhuxiao().then(res => {
  165. cacheManager.clearAll();
  166. toast('用户注销成功')
  167. uni.redirectTo({
  168. url: '/pages/login/index'
  169. });
  170. }).catch(err => {
  171. toast('失败,请稍后重试')
  172. })
  173. }
  174. function yonghuzhuxiao() {
  175. zhuxiaoDialogRef.value.handleShow();
  176. }
  177. function duihuamaDuihuan() {
  178. duihuanmaDialogRef.value.handleShow();
  179. }
  180. function duihuanmaBtn(data) {
  181. console.log('data', data);
  182. let req = {
  183. code: data
  184. }
  185. duihuanmaCode(req).then(res => {
  186. if (res.code == 0) {
  187. toast('兑换成功')
  188. const localList = cacheManager.get('auth').levelIdList || []
  189. const mergeList = [...new Set([...localList, ...res.data.levelIdList])]
  190. cacheManager.updateObject('auth', {
  191. levelIdList: mergeList
  192. })
  193. uni.redirectTo({
  194. url: '/pages/my/index'
  195. })
  196. } else {
  197. toast('兑换失败请重试或联系管理员')
  198. return false
  199. }
  200. }).catch(err => {
  201. })
  202. }
  203. function yinsizhengce() {
  204. agreeType.value = 'ystk'
  205. agreeContentDialogRef.value.handleShow();
  206. }
  207. function kefudianhua() {
  208. kefuDialogRef.value.handleShow();
  209. }
  210. function kefuBtn() {
  211. kefuDialogRef.value.handleClose();
  212. }
  213. // 游客弹窗---确定
  214. function ykConfirm() {
  215. uni.redirectTo({
  216. url: '/pages/login/index'
  217. });
  218. }
  219. function yingyongshezhi() {
  220. uni.redirectTo({
  221. url: '/pages/my/yingyongshezhi'
  222. });
  223. }
  224. // 手机号码
  225. function telClick() {
  226. if (loginFlag.value) {
  227. telDialogFlag.value = true;
  228. } else {
  229. youkeDialogRef.value.handleShow();
  230. }
  231. }
  232. // 手机号码绑定
  233. function bindBtn() {
  234. telDialogFlag.value = false;
  235. myGetAuth()
  236. }
  237. // 关闭手机号码弹窗
  238. function telClose() {
  239. telDialogFlag.value = false;
  240. }
  241. // 关于我们
  242. function aboutClick() {
  243. if (loginFlag.value) {
  244. uni.redirectTo({
  245. url: '/pages/my/aboutPage'
  246. });
  247. } else {
  248. uni.redirectTo({
  249. url: `/pages/my/aboutPage?levelId=${routerOpt.levelId}&typeId=${routerOpt.typeId}&subjectId=${routerOpt.subjectId}&tipFlag=${routerOpt.tipFlag}`
  250. });
  251. }
  252. }
  253. function sxtkClick() {
  254. uni.redirectTo({
  255. url: '/pages/my/sxtkPage'
  256. });
  257. }
  258. function xxjlClick() {
  259. uni.redirectTo({
  260. url: '/pages/my/xuexiJilu'
  261. });
  262. }
  263. // 产品商城
  264. function cpscClick() {
  265. if (loginFlag.value) {
  266. uni.redirectTo({
  267. url: '/pages/mall/mallPage'
  268. });
  269. } else {
  270. uni.redirectTo({
  271. url: `/pages/mall/mallPage?levelId=${routerOpt.levelId}&typeId=${routerOpt.typeId}&subjectId=${routerOpt.subjectId}&tipFlag=${routerOpt.tipFlag}`
  272. });
  273. }
  274. }
  275. // 订单
  276. function orderClick() {
  277. if (loginFlag.value) {
  278. uni.redirectTo({
  279. url: '/pages/pay/order'
  280. });
  281. } else {
  282. youkeDialogRef.value.handleShow();
  283. }
  284. }
  285. // 获取用户数据
  286. function getMyInfo() {
  287. myInfo({}).then(res => {
  288. getUserImg(res.data.growthType)
  289. myInfoData.userName = res.data.userName;
  290. myInfoData.credit = res.data.credit;
  291. })
  292. getMyCardList();
  293. }
  294. // 登录人员的cardlist
  295. function getMyCardList() {
  296. myCardList({}).then(res => {
  297. bannerArr.value = res.data;
  298. })
  299. }
  300. // 游客的cardList
  301. function getCommonCardList() {
  302. commonCardList({}).then(res => {
  303. bannerArr.value = res.data;
  304. })
  305. }
  306. // 获取用户头像
  307. function getUserImg(data) {
  308. switch (data) {
  309. case 0:
  310. myInfoData.userImg = 'static/images/my/head-img0.png'
  311. break;
  312. case 1:
  313. myInfoData.userImg = 'static/images/my/head-img1.png'
  314. break;
  315. case 2:
  316. myInfoData.userImg = 'static/images/my/head-img2.png'
  317. break;
  318. case 3:
  319. myInfoData.userImg = 'static/images/my/head-img3.png'
  320. break;
  321. default:
  322. myInfoData.userImg = 'static/images/my/head-unlogin-img.png'
  323. break;
  324. }
  325. }
  326. // 点击card
  327. function hyqyBtn(data) {
  328. if (loginFlag.value) {
  329. uni.redirectTo({
  330. url: '/pages/mall/mallPage?cardId=' + data.id + '&subjectId=' + data.subjectId + '&from=myPage'
  331. })
  332. } else {
  333. uni.redirectTo({
  334. url: `/pages/mall/mallPage?levelId=${routerOpt.levelId}&typeId=${routerOpt.typeId}&cardId=${data.id}&subjectId=${data.subjectId}&tipFlag=${routerOpt.tipFlag}`
  335. });
  336. }
  337. }
  338. // 判断是否是游客
  339. function myGetAuth() {
  340. let LocalStorage = cacheManager.get('auth');
  341. if (LocalStorage) {
  342. // 非游客
  343. noYoukeFun()
  344. } else {
  345. youkeFun();
  346. }
  347. }
  348. // 游客
  349. function youkeFun() {
  350. // 获取广告
  351. getCommonCardList();
  352. levelId.value = routerOpt.levelId
  353. typeId.value = routerOpt.typeId
  354. subjectId.value = routerOpt.subjectId
  355. tipFlag.value = routerOpt.tipFlag
  356. // my游客
  357. loginFlag.value = false;
  358. myInfoData.userName = '游客';
  359. myInfoData.userImg = 'static/images/my/head-unlogin-img.png'
  360. }
  361. // 非游客
  362. function noYoukeFun() {
  363. loginFlag.value = true;
  364. getMyInfo();
  365. }
  366. function isIOSorAndroid() {
  367. const systemInfo = uni.getSystemInfoSync();
  368. console.log('systemInfo', systemInfo);
  369. if (systemInfo.platform == 'ios') {
  370. return currentPlatform.value = 'ios'
  371. } else {
  372. return currentPlatform.value = 'android'
  373. }
  374. }
  375. onLoad((options) => {
  376. if (!cacheManager.get('auth')) {
  377. // 游客
  378. routerOpt = options;
  379. } else {
  380. appleCode.value = cacheManager.get("auth").appleCode.toString()
  381. isIOSorAndroid()
  382. }
  383. })
  384. function checkWrong() {
  385. if (loginFlag.value) {
  386. const AuthCode = getUserIdentity();
  387. if (AuthCode == 'Visitor') {
  388. youkeDialogRef.value.handleShow();
  389. return;
  390. }
  391. uni.redirectTo({
  392. url: '/pages/wrong/index'
  393. })
  394. } else {
  395. youkeDialogRef.value.handleShow();
  396. }
  397. }
  398. </script>