index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. <template>
  2. <view class="new-users copy-data" :style="{ height: pageHeight }">
  3. <view class="top" :style="colorStyle">
  4. <!-- #ifdef MP || APP-PLUS -->
  5. <view class="sys-head">
  6. <view class="sys-bar" :style="{ height: sysHeight }"></view>
  7. <!-- #ifdef MP -->
  8. <view
  9. class="sys-title"
  10. :style="member_style == 3 ? 'color:#333' : ''"
  11. >{{ $t("个人中心") }}</view
  12. >
  13. <!-- #endif -->
  14. <view
  15. class="bg"
  16. :style="member_style == 3 ? 'background:#f5f5f5' : ''"
  17. ></view>
  18. </view>
  19. <!-- #endif -->
  20. </view>
  21. <PageDesign
  22. :style="colorStyle"
  23. :diyData="currentDiyData"
  24. :isHome="false"
  25. :isScrolled="isScrolled"
  26. :isFixed="isFixed"
  27. :belongIndex="belongIndex"
  28. @bindSortId="bindSortId"
  29. @bindHeight="bindHeighta"
  30. @storeTap="storeTap"
  31. @changeLogin="changeLogin"
  32. @changeBarg="changeBarg"
  33. @goDetail="goDetail"
  34. ></PageDesign>
  35. <image :src="copyRightPic" alt="" class="support"></image>
  36. <editUserModal
  37. :isShow="editModal"
  38. @closeEdit="closeEdit"
  39. @editSuccess="editSuccess"
  40. ></editUserModal>
  41. <pageFooter :style="colorStyle"></pageFooter>
  42. </view>
  43. </template>
  44. <script>
  45. let sysHeight = uni.getWindowInfo().statusBarHeight + "px";
  46. import {
  47. getMenuList,
  48. getUserInfo,
  49. setVisit,
  50. mpBindingPhone,
  51. } from "@/api/user.js";
  52. import { getThemeInfo } from "@/api/api.js";
  53. import { wechatAuthV2, silenceAuth } from "@/api/public.js";
  54. import { toLogin } from "@/libs/login.js";
  55. import { mapState, mapGetters } from "vuex";
  56. // #ifdef H5
  57. import Auth from "@/libs/wechat";
  58. // #endif
  59. const app = getApp();
  60. import dayjs from "@/plugin/dayjs/dayjs.min.js";
  61. import Routine from "@/libs/routine";
  62. import colors from "@/mixins/color";
  63. import pageFooter from "@/components/pageFooter/index.vue";
  64. import { getCustomer } from "@/utils/index.js";
  65. import editUserModal from "@/components/eidtUserModal/index.vue";
  66. import couponWindow from "@/components/couponWindow/index";
  67. import waterfallsFlow from "@/components/WaterfallsFlow/WaterfallsFlow.vue";
  68. import emptyPage from "@/components/emptyPage.vue";
  69. import Loading from "@/components/Loading/index.vue";
  70. import { getCrmebCopyRight } from "@/api/api.js";
  71. import { goShopDetail } from "@/libs/order.js";
  72. import PageDesign from "@/subpackage/diyComponents/pageDesign.vue";
  73. export default {
  74. components: {
  75. pageFooter,
  76. editUserModal,
  77. PageDesign,
  78. couponWindow,
  79. waterfallsFlow,
  80. emptyPage,
  81. Loading,
  82. },
  83. // computed: mapGetters(['isLogin','cartNum']),
  84. computed: {
  85. pdHeights() {
  86. return { height: "100rpx" };
  87. },
  88. ...mapGetters({
  89. cartNum: "cartNum",
  90. isLogin: "isLogin",
  91. }),
  92. },
  93. filters: {
  94. coundTime(val) {
  95. var setTime = val * 1000;
  96. var nowTime = new Date();
  97. var rest = setTime - nowTime.getTime();
  98. var day = parseInt(rest / (60 * 60 * 24 * 1000));
  99. // var hour = parseInt(rest/(60*60*1000)%24) //小时
  100. return day + this.$t("day");
  101. },
  102. dateFormat: function (value) {
  103. return dayjs(value * 1000).format("YYYY-MM-DD");
  104. },
  105. },
  106. mixins: [colors],
  107. data() {
  108. return {
  109. currentDiyData: {},
  110. editModal: false, // 编辑头像信息
  111. storeMenu: [], // 商家管理
  112. orderMenu: [
  113. {
  114. img: "icon-daifukuan",
  115. title: "待付款",
  116. url: "/pages/goods/order_list/index?status=0",
  117. },
  118. {
  119. img: "icon-daifahuo",
  120. title: "待发货",
  121. url: "/pages/goods/order_list/index?status=1",
  122. },
  123. {
  124. img: "icon-daishouhuo",
  125. title: "待收货",
  126. url: "/pages/goods/order_list/index?status=2",
  127. },
  128. {
  129. img: "icon-daipingjia",
  130. title: "待评价",
  131. url: "/pages/goods/order_list/index?status=3",
  132. },
  133. {
  134. img: "icon-a-shouhoutuikuan",
  135. title: "售后/退款",
  136. url: "/pages/users/user_return_list/index",
  137. },
  138. ],
  139. imgUrls: [],
  140. autoplay: true,
  141. circular: true,
  142. interval: 3000,
  143. duration: 500,
  144. isAuto: false, //没有授权的不会自动授权
  145. isShowAuth: false, //是否隐藏授权
  146. orderStatusNum: {},
  147. userInfo: {},
  148. MyMenus: [],
  149. sysHeight: sysHeight,
  150. mpHeight: 0,
  151. showStatus: 1,
  152. activeRouter: "",
  153. // #ifdef H5 || MP
  154. pageHeight: "100%",
  155. routineContact: 0,
  156. // #endif
  157. // #ifdef APP-PLUS
  158. pageHeight: app.globalData.windowHeight,
  159. // #endif
  160. // #ifdef H5
  161. isWeixin: Auth.isWeixin(),
  162. //#endif
  163. footerSee: false,
  164. my_menus_status: 0,
  165. business_status: 0,
  166. member_style: 0,
  167. my_banner_status: 0,
  168. is_diy: uni.getStorageSync("is_diy"),
  169. copyRightPic: require("static/images/support.png"), //版权图片
  170. belongIndex: 0,
  171. isScrolled: false,
  172. isFixed: false,
  173. product_video_status: false,
  174. positionTop: 0,
  175. sortMpTop: 0,
  176. sortList: [],
  177. curSort: 0,
  178. goodList: [],
  179. loaded: false,
  180. loading: false,
  181. isCouponShow: false,
  182. couponObj: {},
  183. site_config: "",
  184. configData: {},
  185. isFooter: false,
  186. entryData: { select_store_id: "", store_id: "" },
  187. sid: 0,
  188. goodPage: 1,
  189. };
  190. },
  191. onLoad(option) {
  192. uni.hideTabBar();
  193. let that = this;
  194. // #ifdef MP
  195. // 小程序静默授权
  196. if (!this.$store.getters.isLogin) {
  197. // Routine.getCode()
  198. // .then(code => {
  199. // Routine.silenceAuth(code).then(res => {
  200. // this.onLoadFun();
  201. // })
  202. // })
  203. // .catch(res => {
  204. // uni.hideLoading();
  205. // });
  206. }
  207. // #endif
  208. // #ifdef H5 || APP-PLUS
  209. // if (that.isLogin == false) {
  210. // toLogin();
  211. // }
  212. //获取用户信息回来后授权
  213. let cacheCode = this.$Cache.get("snsapi_userinfo_code");
  214. let res1 = cacheCode ? option.code != cacheCode : true;
  215. if (
  216. this.isWeixin &&
  217. option.code &&
  218. res1 &&
  219. option.scope === "snsapi_userinfo"
  220. ) {
  221. this.$Cache.set("snsapi_userinfo_code", option.code);
  222. Auth.auth(option.code)
  223. .then((res) => {
  224. this.getUserInfo();
  225. })
  226. .catch((err) => {});
  227. }
  228. // #endif
  229. // #ifdef APP-PLUS
  230. that.$set(that, "pageHeight", app.globalData.windowHeight);
  231. // #endif
  232. let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
  233. let curRoute = routes[routes.length - 1].route; //获取当前页面路由
  234. this.activeRouter = "/" + curRoute;
  235. this.getCopyRight();
  236. },
  237. onReady() {
  238. let self = this;
  239. // #ifdef MP
  240. let info = uni.createSelectorQuery().select(".sys-head");
  241. info
  242. .boundingClientRect(function (data) {
  243. //data - 各种参数
  244. self.mpHeight = data.height;
  245. })
  246. .exec();
  247. // #endif
  248. },
  249. onShow: function () {
  250. let that = this;
  251. // #ifdef APP-PLUS
  252. uni.getSystemInfo({
  253. success: function (res) {
  254. that.pageHeight = res.windowHeight + "px";
  255. },
  256. });
  257. // #endif
  258. if (that.isLogin) {
  259. this.getUserInfo();
  260. this.setVisit();
  261. }
  262. this.getMyMenus();
  263. this.getDiyData();
  264. this.getCopyRight();
  265. },
  266. onPullDownRefresh() {
  267. this.onLoadFun();
  268. },
  269. onPageScroll() {
  270. uni.$emit("scroll");
  271. },
  272. methods: {
  273. bindSortId(data) {
  274. if (data.dataType.tabVal == 1) {
  275. uni.navigateTo({
  276. url: `/pages/goods/goods_list/index?cid=${data.classPage.id}&title=${data.classPage.name}`,
  277. });
  278. } else if (data.text.val == '首页') {
  279. uni.switchTab({
  280. url: `/pages/index/index`,
  281. });
  282. } else {
  283. uni.navigateTo({
  284. url: `/pages/annex/special/index?theme_id=${data.microPage.id}`,
  285. });
  286. }
  287. },
  288. storeTap(id) {
  289. this.entryData.select_store_id = id;
  290. this.entryData.store_id = "";
  291. uni.removeStorageSync("rulesStoreId");
  292. },
  293. bindHeighta(data) {
  294. // #ifdef APP-PLUS
  295. this.sortMpTop = data.top + data.height;
  296. // #endif
  297. },
  298. changeSort(item, index) {
  299. if (this.curSort == index) return;
  300. this.curSort = index;
  301. this.sid = item.id;
  302. this.goodList = [];
  303. this.goodPage = 1;
  304. this.loaded = false;
  305. if (this.getGoodsList) this.getGoodsList();
  306. },
  307. goDetail(item) {
  308. goShopDetail(item, this.$store.state.app.uid).then((res) => {
  309. uni.navigateTo({
  310. url: `/pages/goods_details/index?id=${item.id}`,
  311. });
  312. });
  313. },
  314. couponClose() {
  315. this.isCouponShow = false;
  316. if (!uni.getStorageSync("oldUser") && this.getNewCoupon) {
  317. this.getNewCoupon();
  318. }
  319. },
  320. goICP(url) {
  321. // #ifdef H5
  322. window.open(url);
  323. // #endif
  324. // #ifdef MP
  325. uni.navigateTo({
  326. url: `/pages/annex/web_view/index?url=${url}`,
  327. });
  328. // #endif
  329. },
  330. changeBarg(item) {
  331. if (!this.isLogin) {
  332. toLogin();
  333. } else {
  334. uni.navigateTo({
  335. url: `/pages/activity/goods_bargain_details/index?id=${item.id}&spid=${this.$store.state.app.uid}`,
  336. });
  337. }
  338. },
  339. changeLogin() {
  340. if (!this.isLogin) {
  341. toLogin();
  342. }
  343. },
  344. objToArr(data) {
  345. if (!data || typeof data !== "object") return [];
  346. let obj = Object.keys(data).sort();
  347. let m = obj.map((key) => data[key]);
  348. return m;
  349. },
  350. getDiyData() {
  351. let previewThemeId = uni.getStorageSync("previewThemeId");
  352. let data = {};
  353. if (previewThemeId) data.theme_id = previewThemeId;
  354. getThemeInfo("user", data).then((res) => {
  355. this.currentDiyData = res.data;
  356. });
  357. },
  358. getWechatuserinfo() {
  359. //#ifdef H5
  360. Auth.isWeixin() && Auth.toAuth("snsapi_userinfo", "/pages/user/index");
  361. //#endif
  362. },
  363. editSuccess() {
  364. this.editModal = false;
  365. this.getUserInfo();
  366. },
  367. closeEdit() {
  368. this.editModal = false;
  369. },
  370. // 记录会员访问
  371. setVisit() {
  372. setVisit({
  373. url: "/pages/user/index",
  374. }).then((res) => {});
  375. },
  376. // 打开授权
  377. openAuto() {
  378. toLogin();
  379. },
  380. // 授权回调
  381. onLoadFun() {
  382. this.getUserInfo();
  383. this.getMyMenus();
  384. this.getDiyData();
  385. this.setVisit();
  386. },
  387. Setting: function () {
  388. uni.openSetting({
  389. success: function (res) {},
  390. });
  391. },
  392. // 授权关闭
  393. authColse: function (e) {
  394. this.isShowAuth = e;
  395. },
  396. // 绑定手机
  397. bindPhone() {
  398. uni.navigateTo({
  399. url: "/pages/users/user_phone/index",
  400. });
  401. },
  402. getphonenumber(e) {
  403. if (e.detail.errMsg == "getPhoneNumber:ok") {
  404. Routine.getCode()
  405. .then((code) => {
  406. let data = {
  407. code,
  408. iv: e.detail.iv,
  409. encryptedData: e.detail.encryptedData,
  410. };
  411. mpBindingPhone(data)
  412. .then((res) => {
  413. this.getUserInfo();
  414. this.$util.Tips({
  415. title: res.msg,
  416. icon: "success",
  417. });
  418. })
  419. .catch((err) => {
  420. return this.$util.Tips({
  421. title: err,
  422. });
  423. });
  424. })
  425. .catch((error) => {
  426. uni.hideLoading();
  427. });
  428. }
  429. },
  430. /**
  431. * 获取个人用户信息
  432. */
  433. getUserInfo: function () {
  434. let that = this;
  435. getUserInfo().then((res) => {
  436. that.userInfo = res.data;
  437. this.$store.commit("UPDATE_USERINFO", res.data);
  438. that.$store.commit("SETUID", res.data.uid);
  439. that.orderMenu.forEach((item, index) => {
  440. switch (item.title) {
  441. case "待付款":
  442. item.num = res.data.orderStatusNum.unpaid_count;
  443. break;
  444. case "待发货":
  445. item.num = res.data.orderStatusNum.unshipped_count;
  446. break;
  447. case "待收货":
  448. item.num = res.data.orderStatusNum.received_count;
  449. break;
  450. case "待评价":
  451. item.num = res.data.orderStatusNum.evaluated_count;
  452. break;
  453. case "售后/退款":
  454. item.num = res.data.orderStatusNum.refunding_count;
  455. break;
  456. }
  457. });
  458. uni.stopPullDownRefresh();
  459. });
  460. },
  461. //小程序授权api替换 getUserInfo
  462. getUserProfile() {
  463. toLogin();
  464. },
  465. /**
  466. *
  467. * 获取个人中心图标
  468. */
  469. switchTab(order) {
  470. this.orderMenu.forEach((item, index) => {
  471. switch (item.title) {
  472. case "待付款":
  473. item.img = order.dfk;
  474. break;
  475. case "待发货":
  476. item.img = order.dfh;
  477. break;
  478. case "待收货":
  479. item.img = order.dsh;
  480. break;
  481. case "待评价":
  482. item.img = order.dpj;
  483. break;
  484. case "售后/退款":
  485. item.img = order.sh;
  486. break;
  487. }
  488. });
  489. },
  490. getMyMenus: function () {
  491. let that = this;
  492. // if (this.MyMenus.length) return;
  493. getMenuList().then((res) => {
  494. this.member_style = Number(res.data.diy_data.value);
  495. this.my_banner_status = res.data.diy_data.my_banner_status;
  496. this.my_menus_status = res.data.diy_data.my_menus_status;
  497. this.business_status = res.data.diy_data.business_status;
  498. let storeMenu = [];
  499. let myMenu = [];
  500. res.data.routine_my_menus.forEach((el, index, arr) => {
  501. if (
  502. el.url == "/pages/admin/order/index" ||
  503. el.url == "/pages/admin/order_cancellation/index" ||
  504. el.url == "/pages/admin/manage/index" ||
  505. el.name == "客服接待"
  506. ) {
  507. storeMenu.push(el);
  508. } else {
  509. myMenu.push(el);
  510. }
  511. });
  512. let order01 = {
  513. dfk: "icon-daifukuan",
  514. dfh: "icon-daifahuo",
  515. dsh: "icon-daishouhuo",
  516. dpj: "icon-daipingjia",
  517. sh: "icon-a-shouhoutuikuan",
  518. };
  519. let order02 = {
  520. dfk: "icon-daifukuan-lan",
  521. dfh: "icon-daifahuo-lan",
  522. dsh: "icon-daishouhuo-lan",
  523. dpj: "icon-daipingjia-lan",
  524. sh: "icon-shouhoutuikuan-lan",
  525. };
  526. let order03 = {
  527. dfk: "icon-daifukuan-ju",
  528. dfh: "icon-daifahuo-ju",
  529. dsh: "icon-daishouhuo-ju",
  530. dpj: "icon-daipingjia-ju",
  531. sh: "icon-shouhoutuikuan-ju",
  532. };
  533. let order04 = {
  534. dfk: "icon-daifukuan-fen",
  535. dfh: "icon-daifahuo-fen",
  536. dsh: "icon-daishouhuo-fen",
  537. dpj: "icon-daipingjia-fen",
  538. sh: "icon-shouhoutuikuan-fen",
  539. };
  540. let order05 = {
  541. dfk: "icon-daifukuan-lv",
  542. dfh: "icon-daifahuo-lv",
  543. dsh: "icon-daishouhuo-lv",
  544. dpj: "icon-daipingjia-lv",
  545. sh: "icon-shouhoutuikuan-lv",
  546. };
  547. if (this.member_style == 1) {
  548. this.switchTab(order01);
  549. } else if (this.member_style == 2) {
  550. this.switchTab(order02);
  551. } else if (this.member_style == 3) {
  552. this.switchTab(order03);
  553. } else if (this.member_style == 4) {
  554. this.switchTab(order04);
  555. } else if (this.member_style == 5) {
  556. this.switchTab(order05);
  557. }
  558. this.storeMenu = storeMenu;
  559. this.MyMenus = myMenu;
  560. });
  561. },
  562. getCopyRight() {
  563. getCrmebCopyRight().then((res) => {
  564. if (res.data.copyrightImage)
  565. this.copyRightPic = res.data.copyrightImage;
  566. });
  567. },
  568. },
  569. };
  570. </script>
  571. <style lang="scss">
  572. .new-users {
  573. padding-bottom: 100rpx;
  574. .sys-head {
  575. position: relative;
  576. width: 100%;
  577. background: #fff;
  578. z-index: 50;
  579. .sys-bar {
  580. width: 100%;
  581. }
  582. .sys-title {
  583. width: 100%;
  584. height: 43px;
  585. line-height: 43px;
  586. text-align: center;
  587. font-size: 32rpx;
  588. color: #000;
  589. font-weight: 500;
  590. position: relative;
  591. z-index: 10;
  592. }
  593. .bg {
  594. position: absolute;
  595. left: 0;
  596. top: 0;
  597. width: 100%;
  598. height: 100%;
  599. z-index: 5;
  600. }
  601. }
  602. .support {
  603. width: 219rpx;
  604. height: 74rpx;
  605. margin: 54rpx auto;
  606. display: block;
  607. }
  608. }
  609. </style>