index.ux 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <import name="home-page" src="../Home/index.ux"></import>
  2. <import name="category-page" src="../Category/index.ux"></import>
  3. <import name="shelf-page" src="../Shelf/index.ux"></import>
  4. <import name="my-page" src="../My/index.ux"></import>
  5. <import name="sign-page" src="../../components/sign/index.ux"></import>
  6. <import name="short-page" src="../../components/short/index.ux"></import>
  7. <template>
  8. <stack class="stack-wrap">
  9. <div class="index-wrap">
  10. <tabs class="tab-content" onchange="tabbarChange" index="{{current}}">
  11. <tab-content>
  12. <home-page @change="pageSwitch" tabindex="{{current}}"></home-page>
  13. <category-page tabindex="{{current}}"></category-page>
  14. <shelf-page @change="pageSwitch" tabindex='{{current}}'></shelf-page>
  15. <my-page @customer="openCustomer" tabindex="{{current}}"></my-page>
  16. </tab-content>
  17. </tabs>
  18. <div class="fixed-tabbar">
  19. <image src="../../assets/imgs/shadow.png" class="shadow"></image>
  20. <div class="tabbar-item__wrap">
  21. <block for="tab in tabbar">
  22. <div class="tabbar-item " @click="tabbarChange(tab)">
  23. <image src="{{tab.index === current ? tab.active_icon : tab.icon}}"></image>
  24. <text class="{{tab.index === current ? 'tabbar-name__cur' : ''}}">{{tab.name}}</text>
  25. </div>
  26. </block>
  27. </div>
  28. </div>
  29. </div>
  30. <image src="../../assets/imgs/sign_show.png" class="sign-icon" @click="changeSignPop"> </image>
  31. <sign-page if="showSignPop"></sign-page>
  32. <short-page if="showShortPop" @hasShort="hasShort"></short-page>
  33. <div class="stack-popup" @click="closeWrap" if="showPopup">
  34. <div class="customer-popup">
  35. <text class="title">联系客服</text>
  36. <text class="desc">
  37. 复制微信号或者保存二维码到本地至微信添加客服好友
  38. </text>
  39. <image src="{{cutomerQrcode}}" @longpress="saveImg"></image>
  40. <div class="duplication"><text class="duplication-text">微信号:{{cutomerName}}</text><text class="duplication-button" @click="duplication">复制</text></div>
  41. </div>
  42. </div>
  43. </stack>
  44. </template>
  45. <script>
  46. import clipboard from '@system.clipboard';
  47. import prompt from '@system.prompt';
  48. import it from "../../helper/interface.js";
  49. import { getCustomQrcode } from '../../api/index.js';
  50. import { downImg, getStore } from '../../api/utils.js';
  51. export default {
  52. private: {
  53. tabbar: [
  54. {
  55. name: "首页",
  56. title: "追书云",
  57. icon: "../../assets/imgs/home.png",
  58. active_icon: "../../assets/imgs/home_choose.png",
  59. index: 0
  60. },
  61. {
  62. name: "分类",
  63. title: "书城",
  64. icon: "../../assets/imgs/category.png",
  65. active_icon: "../../assets/imgs/category_choose.png",
  66. index: 1
  67. },
  68. {
  69. name: "书架",
  70. title: "我的书架",
  71. icon: "../../assets/imgs/shelf.png",
  72. active_icon: "../../assets/imgs/shelf_choose.png",
  73. index: 2
  74. },
  75. {
  76. name: "我的",
  77. title: "个人中心",
  78. icon: "../../assets/imgs/my.png",
  79. active_icon: "../../assets/imgs/my_choose.png",
  80. index: 3
  81. }
  82. ],
  83. current: 0,
  84. showPopup: false,
  85. showSignPop: false,
  86. showShortPop: false,
  87. cutomerQrcode: '',
  88. cutomerName: ''
  89. },
  90. onInit() {
  91. this.$on('dispathEvt', this.changeSignPop);
  92. this.$on('hasShort',this.changeShortCut);
  93. //今日已签到过不在弹框签到
  94. this.getCoustom();
  95. },
  96. onShow() {
  97. it.getShortCut((value) => {
  98. this.showShortPop = !value;
  99. })
  100. },
  101. onBackPress() {
  102. // 退出逻辑
  103. if (this.$app.$def.data.backClickCount === 0) {
  104. this.$app.$def.data.backClickCount++;
  105. this.$app.$def.createShortcut()
  106. return true;
  107. }
  108. },
  109. /**
  110. * 当用户点击菜单按钮时触发,调用app中定义的方法showMenu
  111. * 注意:使用加载器测试`创建桌面快捷方式`功能时,请先在`系统设置`中打开`应用加载器`的`桌面快捷方式`权限
  112. */
  113. onMenuPress() {
  114. this.$app.$def.showMenu();
  115. },
  116. changeShortCut(){
  117. this.showShortPop=false;
  118. },
  119. async getCoustom() {
  120. let res = await getCustomQrcode();
  121. this.cutomerQrcode = res.url;
  122. this.cutomerName = res.name;
  123. },
  124. tabbarChange(tab) {
  125. this.current = tab.index;
  126. this.$page.setTitleBar({ text: this.tabbar[tab.index].title });
  127. },
  128. pageSwitch() {
  129. this.current = 1;
  130. },
  131. changeSignPop() {
  132. this.showSignPop = !this.showSignPop;
  133. },
  134. closeWrap() {
  135. this.showPopup = false;
  136. },
  137. //复制客服微信
  138. duplication() {
  139. clipboard.set({
  140. text: this.cutomerName,
  141. success: function (data) {
  142. prompt.showToast({
  143. message: '复制成功!'
  144. })
  145. },
  146. })
  147. },
  148. //长按保存图片
  149. saveImg() {
  150. downImg(this.cutomerQrcode);
  151. },
  152. openCustomer() {
  153. this.showPopup = true;
  154. }
  155. }
  156. </script>
  157. <style lang="less">
  158. @import "../../assets/less/index.less";
  159. </style>