123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <template>
- <view class="o-w o-h">
- <!-- 首页 -->
- <k-home ref="kHomeRef" v-show="$S_tabbar_tabIdx === 0"></k-home>
- <!-- 购物车 -->
- <k-car v-show="$S_tabbar_tabIdx === 1"></k-car>
- <!-- 我的 -->
- <k-mine class="o-w o-h" v-show="$S_tabbar_tabIdx === 2"></k-mine>
- <!-- 底部导航栏 -->
- <k-tabbar />
- </view>
- </template>
- <script>
- // 导入登录方法
- import appLogin from '@/common/login.js';
- // 引入我的
- import kMine from './mine/index.vue';
- // 引入首页
- import kHome from './home/index.vue';
- // 引入购物车
- import kCar from './car/index.vue';
- // 引入底部导航栏
- import kTabbar from '@/components/common/k-tabbar/k-tabbar.vue';
- export default {
- // 注册组件
- components: {
- kMine,
- kHome,
- kCar,
- kTabbar
- },
- computed: {
- // 获取vuex的数据,用作控制组件的显示和隐藏
- $S_tabbar_tabIdx() {
- return this.$M_GS('common', '$S_tabbar_tabIdx');
- }
- },
- async onLoad(options) {
- let clientId = options.clientId;
- let flag = options.flag;
- // 如果是扫小程序码进来的
- if (options.scene) {
- const { scene } = options;
- clientId = scene.split('-')[0];
- // 如果存在优惠券
- if (scene.indexOf('-') !== -1) {
- flag = scene.split('-')[1];
- }
- }
- // 登录
- const appLoginData = await appLogin({ clientId, flag });
- // 初始化home页面的数据
- this.$refs.kHomeRef.init(appLoginData);
- },
- // 分享小程序
- onShareAppMessage(res) {
- return {
- title: '申泽智能售卖',
- path: '/pages/index',
- success(res) {
- uni.showToast({
- title: '分享成功'
- });
- },
- fail(res) {
- uni.showToast({
- title: '分享失败',
- icon: 'none'
- });
- }
- };
- }
- };
- </script>
|