index.ux 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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}}" @addshort="shortEnd"></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. protected: {
  53. current: 0
  54. },
  55. private: {
  56. tabbar: [
  57. {
  58. name: "首页",
  59. title: "天天好书",
  60. icon: "../../assets/imgs/home.png",
  61. active_icon: "../../assets/imgs/home_choose.png",
  62. index: 0
  63. },
  64. {
  65. name: "分类",
  66. title: "书城",
  67. icon: "../../assets/imgs/category.png",
  68. active_icon: "../../assets/imgs/category_choose.png",
  69. index: 1
  70. },
  71. {
  72. name: "书架",
  73. title: "我的书架",
  74. icon: "../../assets/imgs/shelf.png",
  75. active_icon: "../../assets/imgs/shelf_choose.png",
  76. index: 2
  77. },
  78. {
  79. name: "我的",
  80. title: "个人中心",
  81. icon: "../../assets/imgs/my.png",
  82. active_icon: "../../assets/imgs/my_choose.png",
  83. index: 3
  84. }
  85. ],
  86. // current: 0,
  87. showPopup: false,
  88. showSignPop: false,
  89. showShortPop: false,
  90. cutomerQrcode: '',
  91. cutomerName: ''
  92. },
  93. onInit() {
  94. this.$on('dispathEvt', this.changeSignPop);
  95. this.$watch('current', 'watchCurrent');
  96. //今日已签到过不在弹框签到
  97. this.getCoustom();
  98. },
  99. onShow() {
  100. const data = this.$app.getAppData('backfrom');
  101. if(data=='phone'){
  102. this.current = 1;
  103. this.$app.setAppData('backfrom','');
  104. }
  105. it.getShortCut((value) => {
  106. this.showShortPop = !value;
  107. })
  108. },
  109. shortEnd(value) {
  110. if (value.detail.msg) {
  111. prompt.showToast({ message: "用户禁止创建" });
  112. }
  113. this.showShortPop = !value.detail.installed;
  114. },
  115. watchCurrent(i) {
  116. console.log("watching", i);
  117. this.current = i;
  118. },
  119. onBackPress() {
  120. // 退出逻辑
  121. if (this.$app.$def.data.backClickCount === 0) {
  122. this.$app.$def.data.backClickCount++;
  123. this.$app.$def.createShortcut();
  124. return true;
  125. }
  126. },
  127. /**
  128. * 当用户点击菜单按钮时触发,调用app中定义的方法showMenu
  129. * 注意:使用加载器测试`创建桌面快捷方式`功能时,请先在`系统设置`中打开`应用加载器`的`桌面快捷方式`权限
  130. */
  131. onMenuPress() {
  132. this.$app.$def.showMenu();
  133. },
  134. changeShortCut() {
  135. this.showShortPop = false;
  136. },
  137. async getCoustom() {
  138. let res = await getCustomQrcode();
  139. this.cutomerQrcode = res.url;
  140. this.cutomerName = res.name;
  141. },
  142. tabbarChange(tab) {
  143. this.current = tab.index;
  144. this.$page.setTitleBar({ text: this.tabbar[tab.index].title });
  145. },
  146. pageSwitch() {
  147. this.current = 1;
  148. },
  149. changeSignPop() {
  150. this.showSignPop = !this.showSignPop;
  151. },
  152. closeWrap() {
  153. this.showPopup = false;
  154. },
  155. //复制客服微信
  156. duplication() {
  157. clipboard.set({
  158. text: this.cutomerName,
  159. success: function (data) {
  160. prompt.showToast({
  161. message: '复制成功!'
  162. })
  163. },
  164. })
  165. },
  166. //长按保存图片
  167. saveImg() {
  168. downImg(this.cutomerQrcode);
  169. },
  170. openCustomer() {
  171. this.showPopup = true;
  172. }
  173. }
  174. </script>
  175. <style lang="less">
  176. @import "../../assets/less/index.less";
  177. </style>