App.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <script>
  2. import {
  3. checkLogin
  4. } from "./libs/login";
  5. import {
  6. HTTP_REQUEST_URL
  7. } from './config/app';
  8. import {
  9. getconfig,
  10. history
  11. } from '@/api/public.js'
  12. export default {
  13. globalData: {
  14. spid: 0,
  15. code: 0,
  16. isLogin: false,
  17. userInfo: {},
  18. MyMenus: [],
  19. balance_func_status: 0, //余额开关
  20. recharge_switch: 0, // 充值开关
  21. store_user_min_recharge: 0, //最小充值
  22. yue_pay_status: 0, //余额支付开关
  23. alipay_open: 0, //支付宝支付开关
  24. routine_logo: '', //首页logo
  25. site_logo: '',
  26. site_name: '', //名称
  27. fid: '', //一级分类id
  28. uid: '',
  29. hide_mer_status: 0,
  30. },
  31. onLaunch: function(option) {
  32. console.log(this.$store)
  33. console.log()
  34. this.globalData.uid = this.$store.state.app.uid
  35. let that = this;
  36. // #ifdef MP
  37. if (HTTP_REQUEST_URL == '') {
  38. console.error(
  39. "请配置根目录下的config.js文件中的 'HTTP_REQUEST_URL'\n\n请修改开发者工具中【详情】->【AppID】改为自己的Appid\n\n请前往后台【小程序】->【小程序配置】填写自己的 appId and AppSecret"
  40. );
  41. return false;
  42. }
  43. if (option.query.hasOwnProperty('scene')) {
  44. switch (option.scene) {
  45. //扫描小程序码
  46. case 1047:
  47. console.log(option, 'val')
  48. let val = that.$util.getUrlParams(decodeURIComponent(option.query.scene));
  49. that.globalData.code = val;
  50. that.globalData.uid = val
  51. break;
  52. //长按图片识别小程序码
  53. case 1048:
  54. that.globalData.code = option.query.scene;
  55. break;
  56. //手机相册选取小程序码
  57. case 1049:
  58. that.globalData.code = option.query.scene;
  59. break;
  60. //直接进入小程序
  61. case 1001:
  62. that.globalData.spid = option.query.scene;
  63. break;
  64. }
  65. }
  66. // #endif
  67. // 获取导航高度;
  68. uni.getSystemInfo({
  69. success: function(res) {
  70. that.globalData.navHeight = res.statusBarHeight * (750 / res.windowWidth) + 91;
  71. }
  72. });
  73. // 获取配置
  74. getconfig().then(res => {
  75. uni.$emit('update', res.data)
  76. uni.setStorageSync('GLOBAL_DATA', res.data);
  77. this.globalData.balance_func_status = res.data.balance_func_status
  78. this.globalData.recharge_switch = res.data.recharge_switch
  79. this.globalData.routine_logo = res.data.routine_logo
  80. this.globalData.site_logo = res.data.site_logo
  81. this.globalData.login_logo = res.data.login_logo
  82. this.globalData.site_name = res.data.site_name
  83. this.globalData.store_user_min_recharge = res.data.store_user_min_recharge
  84. this.globalData.yue_pay_status = res.data.yue_pay_status
  85. this.globalData.sys_intention_agree = res.data.sys_intention_agree
  86. this.globalData.mer_intention_open = res.data.mer_intention_open
  87. this.globalData.alipay_open = res.data.alipay_open
  88. this.globalData.hide_mer_status = res.data.hide_mer_status
  89. this.globalData.mer_location = res.data.mer_location
  90. try {
  91. uni.setStorageSync('SUBSCRIBE_MESSAGE', res.data.tempid);
  92. } catch (e) {
  93. // error
  94. }
  95. // #ifdef H5
  96. this.setOpenShare(res.data);
  97. // #endif
  98. }).catch(err => {})
  99. },
  100. onShow() {
  101. // 记录H5和公众号
  102. if (this.$store.state.app.token) {
  103. // 浏览记录
  104. // #ifdef H5
  105. history({
  106. page: location.pathname + location.search,
  107. }).then(() => {});
  108. //#endif
  109. }
  110. },
  111. methods: {
  112. // 微信分享;
  113. setOpenShare: function(data) {
  114. let that = this;
  115. let href = location.href;
  116. href = href.indexOf("?") === -1 ? href + "?spid=" + this.globalData.uid : href + "&spid=" + this.globalData.uid;
  117. if (that.$wechat.isWeixin()) {
  118. let configAppMessage = {
  119. desc: data.share_info,
  120. title: data.share_title,
  121. link: href,
  122. imgUrl: data.share_pic
  123. };
  124. that.$wechat.wechatEvevt(["updateAppMessageShareData", "updateTimelineShareData"], configAppMessage);
  125. }
  126. }
  127. },
  128. onHide: function() {
  129. //console.log('App Hide')
  130. },
  131. watch: {
  132. // 记录H5和公众号
  133. $route(n) {
  134. if (this.$store.state.app.token) {
  135. // 浏览记录
  136. history({
  137. page: location.pathname + location.search,
  138. }).then(() => {});
  139. }
  140. },
  141. }
  142. }
  143. </script>
  144. <style>
  145. @import url("@/plugin/animate/animate.min.css");
  146. @import 'static/css/base.css';
  147. @import 'static/iconfont/iconfont.css';
  148. @import 'static/css/guildford.css';
  149. @import 'static/css/style.scss';
  150. view {
  151. box-sizing: border-box;
  152. }
  153. .bg-color-red {
  154. background-color: #e93323 !important;
  155. }
  156. .syspadding {
  157. padding-top: var(--status-bar-height);
  158. }
  159. .flex {
  160. display: flex;
  161. }
  162. .uni-scroll-view::-webkit-scrollbar {
  163. /* 隐藏滚动条,但依旧具备可以滚动的功能 */
  164. display: none
  165. }
  166. ::-webkit-scrollbar {
  167. width: 0;
  168. height: 0;
  169. color: transparent;
  170. }
  171. ::-moz-scrollbar {
  172. width: 0;
  173. height: 0;
  174. color: transparent;
  175. }
  176. .empty-txt {
  177. line-height: 100rpx;
  178. font-size: 22rpx;
  179. color: #999;
  180. text-align: center;
  181. }
  182. .product-con .conter img {
  183. display: block;
  184. }
  185. .open-location {
  186. height: 100vh;
  187. }
  188. </style>