|
@@ -104,71 +104,21 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
- import {
|
|
|
|
|
- mapState,
|
|
|
|
|
- mapMutations
|
|
|
|
|
- } from 'vuex';
|
|
|
|
|
- import {
|
|
|
|
|
- share
|
|
|
|
|
- } from '@/api/wx';
|
|
|
|
|
- import {
|
|
|
|
|
- loadIndexs,
|
|
|
|
|
- articleList,
|
|
|
|
|
- notify,
|
|
|
|
|
- guide_map
|
|
|
|
|
- } from '@/api/index.js';
|
|
|
|
|
- import {
|
|
|
|
|
- storeList,
|
|
|
|
|
- } from '@/api/shop.js';
|
|
|
|
|
- import onUser from "./indexComponents/onUser.vue"
|
|
|
|
|
- import noUser from "./indexComponents/noUser.vue"
|
|
|
|
|
- // #ifdef MP-WEIXIN
|
|
|
|
|
- import {
|
|
|
|
|
- openGetAddress
|
|
|
|
|
- } from '@/utils/rocessor.js';
|
|
|
|
|
- // #endif
|
|
|
|
|
|
|
+
|
|
|
export default {
|
|
export default {
|
|
|
- components: {
|
|
|
|
|
- onUser,
|
|
|
|
|
- noUser
|
|
|
|
|
- },
|
|
|
|
|
|
|
+
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
carouselList: [],//轮播图
|
|
carouselList: [],//轮播图
|
|
|
- alertImgMapIndex: 0, //引导图流程次数
|
|
|
|
|
- showAlertMap: false, //是否显示引导图
|
|
|
|
|
- userOn: 0, //加载显示页面0不加载1加载已购买车辆页面2加载未购买商品页面
|
|
|
|
|
- articleNum: 0, //消息数
|
|
|
|
|
- notifyNum: 0, //警报数
|
|
|
|
|
- follow: 0, //0为未查询1为关注,2为未关注
|
|
|
|
|
- // #ifndef APP
|
|
|
|
|
- loadFollow: false, //判断是否已经提示过关注公众号
|
|
|
|
|
- // #endif
|
|
|
|
|
- loadShopData: false, //是否已经加载过商家信息
|
|
|
|
|
- alertImgMapList: [], //引导图列表
|
|
|
|
|
- notifyTime: '', //定时器获取消息
|
|
|
|
|
- shareData: {}, //分享数据
|
|
|
|
|
|
|
+
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
computed: {
|
|
computed: {
|
|
|
- ...mapState('user', ['hasLogin', 'userInfo']),
|
|
|
|
|
- ...mapState(['firstUse']),
|
|
|
|
|
- ...mapState('shop', ['shopDetail']),
|
|
|
|
|
- notify() {
|
|
|
|
|
- return this.notifyNum + this.articleNum
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
},
|
|
},
|
|
|
// 切换或显示后变动tabbar颜色
|
|
// 切换或显示后变动tabbar颜色
|
|
|
onHide() {
|
|
onHide() {
|
|
|
- console.log('隐藏');
|
|
|
|
|
- uni.setTabBarStyle({
|
|
|
|
|
- backgroundColor: '#FFFFFF'
|
|
|
|
|
- })
|
|
|
|
|
- if (this.userOn == 1) {
|
|
|
|
|
- this.$refs.onuser.outGetCartInfo()
|
|
|
|
|
- }
|
|
|
|
|
- // 关闭消息定时器
|
|
|
|
|
- clearInterval(this.notifyTime)
|
|
|
|
|
|
|
+
|
|
|
},
|
|
},
|
|
|
onLoad: function(option) {
|
|
onLoad: function(option) {
|
|
|
// #ifndef MP
|
|
// #ifndef MP
|
|
@@ -186,28 +136,12 @@
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
// #endif
|
|
// #endif
|
|
|
- // 初始化商家
|
|
|
|
|
- // this.storeList({})
|
|
|
|
|
- // 获取定位数据
|
|
|
|
|
- this.getlocation();
|
|
|
|
|
- // 加载分享信息
|
|
|
|
|
- // this.share()
|
|
|
|
|
},
|
|
},
|
|
|
onShow() {
|
|
onShow() {
|
|
|
- this.loadIndexs();
|
|
|
|
|
- // 判断是否有用户如果是则显示
|
|
|
|
|
- if (this.userOn == 1) {
|
|
|
|
|
- this.$refs.onuser.setTabbar()
|
|
|
|
|
- this.$refs.onuser.onStartGetCartInfo()
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
},
|
|
},
|
|
|
onReady() {
|
|
onReady() {
|
|
|
- // 判断是否为用户首次加载
|
|
|
|
|
- if (!this.firstUse) {
|
|
|
|
|
- this.showAlertMap = true;
|
|
|
|
|
- this.guide_map();
|
|
|
|
|
- uni.hideTabBar();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
},
|
|
},
|
|
|
// #ifdef MP
|
|
// #ifdef MP
|
|
|
onShareAppMessage(options) {
|
|
onShareAppMessage(options) {
|
|
@@ -217,10 +151,10 @@
|
|
|
let url = currentPage.route; //当前页面url
|
|
let url = currentPage.route; //当前页面url
|
|
|
let item = currentPage.options; //如果要获取url中所带的参数可以查看options
|
|
let item = currentPage.options; //如果要获取url中所带的参数可以查看options
|
|
|
let shareObj = {
|
|
let shareObj = {
|
|
|
- title: this.shareData.title, // 默认是小程序的名称(可以写slogan等)
|
|
|
|
|
|
|
+ title: '租电', // 默认是小程序的名称(可以写slogan等)
|
|
|
path: url, // 默认是当前页面,必须是以‘/’开头的完整路径
|
|
path: url, // 默认是当前页面,必须是以‘/’开头的完整路径
|
|
|
- imageUrl: this.shareData.img,
|
|
|
|
|
- desc: this.shareData.synopsis,
|
|
|
|
|
|
|
+ imageUrl: '',
|
|
|
|
|
+ desc:'',
|
|
|
success: function(res) {
|
|
success: function(res) {
|
|
|
// 转发成功之后的回调
|
|
// 转发成功之后的回调
|
|
|
if (res.errMsg == 'shareAppMessage:ok') {}
|
|
if (res.errMsg == 'shareAppMessage:ok') {}
|
|
@@ -235,215 +169,17 @@
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
// 判断是否可以邀请
|
|
// 判断是否可以邀请
|
|
|
- if (this.userInfo.uid) {
|
|
|
|
|
- shareObj.path += '&spread=' + this.userInfo.uid;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // if (this.userInfo.uid) {
|
|
|
|
|
+ // shareObj.path += '&spread=' + this.userInfo.uid;
|
|
|
|
|
+ // }
|
|
|
return shareObj;
|
|
return shareObj;
|
|
|
},
|
|
},
|
|
|
// #endif
|
|
// #endif
|
|
|
- methods: {
|
|
|
|
|
- ...mapMutations('user', ['setAddress']),
|
|
|
|
|
- // #ifdef APP
|
|
|
|
|
- ...mapMutations(['setFx']),
|
|
|
|
|
- // #endif
|
|
|
|
|
- ...mapMutations(['setFirstUse']),
|
|
|
|
|
- ...mapMutations('shop', ['setShopInfo']),
|
|
|
|
|
- // 获取引导图
|
|
|
|
|
- guide_map() {
|
|
|
|
|
- guide_map().then((e) => {
|
|
|
|
|
- this.alertImgMapList = e.data;
|
|
|
|
|
- console.log(e);
|
|
|
|
|
- }).catch((e) => {
|
|
|
|
|
- console.log(e);
|
|
|
|
|
- })
|
|
|
|
|
- },
|
|
|
|
|
- showcartAlert() {
|
|
|
|
|
- console.log(this.myCartList[this.chickedMyCart]);
|
|
|
|
|
- },
|
|
|
|
|
- // 首次加载点击事件
|
|
|
|
|
- alertClick(e) {
|
|
|
|
|
- // 关闭弹窗
|
|
|
|
|
- this.showAlertMap = false
|
|
|
|
|
- uni.showTabBar()
|
|
|
|
|
- // 设置已经加载过引导图
|
|
|
|
|
- this.setFirstUse(true)
|
|
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
- // 获取经纬度
|
|
|
|
|
- getlocation() {
|
|
|
|
|
- let obj = this;
|
|
|
|
|
- // #ifdef H5 || APP
|
|
|
|
|
- uni.getLocation({
|
|
|
|
|
- type: 'gcj02',
|
|
|
|
|
- success(e) {
|
|
|
|
|
- obj.getlocationSetInit(e)
|
|
|
|
|
- },
|
|
|
|
|
- fail(e) {
|
|
|
|
|
- if(e.errCode==22){
|
|
|
|
|
- uni.showModal({
|
|
|
|
|
- title: '定位开启错误',
|
|
|
|
|
- content: '请查看是否已经开启定位服务',
|
|
|
|
|
- showCancel: false,
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- console.log(e, 'cw');
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- // #endif
|
|
|
|
|
- // #ifdef MP-WEIXIN
|
|
|
|
|
- openGetAddress().then((e) => {
|
|
|
|
|
- console.log("授权");
|
|
|
|
|
- wx.startLocationUpdateBackground({
|
|
|
|
|
- type: 'gcj02',
|
|
|
|
|
- success: (e) => {
|
|
|
|
|
- console.log(e);
|
|
|
|
|
- // 调用鉴定位置变化事件
|
|
|
|
|
- wx.onLocationChange((data) => {
|
|
|
|
|
- obj.getlocationSetInit(data)
|
|
|
|
|
- })
|
|
|
|
|
- },
|
|
|
|
|
- fail() {
|
|
|
|
|
- // uni.getLocation({
|
|
|
|
|
- // type: 'gcj02',
|
|
|
|
|
- // success(e) {
|
|
|
|
|
- // obj.getlocationSetInit(e)
|
|
|
|
|
- // },
|
|
|
|
|
- // fail(e) {
|
|
|
|
|
- // console.log(e, 'cw');
|
|
|
|
|
- // }
|
|
|
|
|
- // })
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- })
|
|
|
|
|
- // #endif
|
|
|
|
|
- },
|
|
|
|
|
- // 获取经纬度完毕后回调处理
|
|
|
|
|
- getlocationSetInit(data) {
|
|
|
|
|
- const obj = this;
|
|
|
|
|
- try {
|
|
|
|
|
- console.log(data, '位置数据');
|
|
|
|
|
- // 保存当前经纬度
|
|
|
|
|
- obj.setAddress({
|
|
|
|
|
- latitude: data.latitude,
|
|
|
|
|
- longitude: data.longitude
|
|
|
|
|
- })
|
|
|
|
|
- // 判断是否已经加载过最近商家信息
|
|
|
|
|
- if (!obj.loadShopData) {
|
|
|
|
|
- obj.storeList({
|
|
|
|
|
- latitude: data.latitude,
|
|
|
|
|
- longitude: data.longitude
|
|
|
|
|
- })
|
|
|
|
|
- obj.loadShopData = true;
|
|
|
|
|
- }
|
|
|
|
|
- } catch (e) {
|
|
|
|
|
- console.log(e, 'cww');
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- // 初始化加载商家数据
|
|
|
|
|
- storeList(data) {
|
|
|
|
|
- let obj = this;
|
|
|
|
|
- storeList(data).then((e) => {
|
|
|
|
|
- // console.log(e.data.list, '商家数据列表');
|
|
|
|
|
- // console.log(e.data.list.length > 0, '商家数据结果');
|
|
|
|
|
- // 保存商店数据
|
|
|
|
|
- if (e.data.list.length > 0) {
|
|
|
|
|
- obj.setShopInfo(e.data.list[0]);
|
|
|
|
|
- obj.$nextTick(() => {
|
|
|
|
|
- if (obj.userOn == 2) {
|
|
|
|
|
- obj.$refs.nouser.init()
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- }).catch((e) => {
|
|
|
|
|
- console.log(e);
|
|
|
|
|
- })
|
|
|
|
|
- },
|
|
|
|
|
- // 首页初始化
|
|
|
|
|
- loadIndexs() {
|
|
|
|
|
- const that = this;
|
|
|
|
|
- // 获取首页数据
|
|
|
|
|
- loadIndexs({
|
|
|
|
|
- store_id: that.shopDetail.id
|
|
|
|
|
- }).then((e) => {
|
|
|
|
|
-
|
|
|
|
|
- // #ifdef APP
|
|
|
|
|
- if(+e.data.app_auth==0){
|
|
|
|
|
- that.setFx(true)
|
|
|
|
|
- }
|
|
|
|
|
- // #endif
|
|
|
|
|
-
|
|
|
|
|
- // #ifdef H5 || MP
|
|
|
|
|
- // 判断是否已经关注了公众号
|
|
|
|
|
- if (e.data.subscribe) {
|
|
|
|
|
- that.follow = 1
|
|
|
|
|
- } else {
|
|
|
|
|
- // 设置已经提示过
|
|
|
|
|
- that.follow = 2
|
|
|
|
|
- // 判断是否未提示过
|
|
|
|
|
- if (!that.loadFollow) {
|
|
|
|
|
- that.loadFollow = true;
|
|
|
|
|
- uni.showModal({
|
|
|
|
|
- title: '提示',
|
|
|
|
|
- content: '您未关注公众号是否马上关注',
|
|
|
|
|
- cancelText: '取消',
|
|
|
|
|
- confirmText: '关注',
|
|
|
|
|
- success: res => {
|
|
|
|
|
- if (res.confirm) {
|
|
|
|
|
- uni.navigateTo({
|
|
|
|
|
- url: './follow',
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- // #endif
|
|
|
|
|
- // 用户车辆大于0则显示用户车辆信息
|
|
|
|
|
- if (e.data.is_car > 0) {
|
|
|
|
|
- that.userOn = 1;
|
|
|
|
|
- // 完成加载后再加载方法防止节点未渲染完成无法找到节点对象
|
|
|
|
|
- that.$nextTick(function() {
|
|
|
|
|
- // 刷新用户数据
|
|
|
|
|
- that.$refs.onuser.loadCard();
|
|
|
|
|
- that.$refs.onuser.setTabbar();
|
|
|
|
|
- })
|
|
|
|
|
- } else {
|
|
|
|
|
- that.userOn = 2;
|
|
|
|
|
- that.$nextTick(function() {
|
|
|
|
|
- // 刷新用户数据
|
|
|
|
|
- that.$refs.nouser.init()
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- }).catch((e) => {
|
|
|
|
|
- console.log(e);
|
|
|
|
|
- })
|
|
|
|
|
- // 判断是否已经用户登录
|
|
|
|
|
- if (that.hasLogin) {
|
|
|
|
|
- if (that.notifyTime) {
|
|
|
|
|
- clearInterval(that.notifyTime)
|
|
|
|
|
- }
|
|
|
|
|
- that.getNotfyNum();
|
|
|
|
|
- that.notifyTime = setInterval(() => {
|
|
|
|
|
- that.getNotfyNum();
|
|
|
|
|
- }, 60000)
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- getNotfyNum() {
|
|
|
|
|
- const that = this;
|
|
|
|
|
- // 查询消息数量
|
|
|
|
|
- articleList({}, 1).then((e) => {
|
|
|
|
|
- that.articleNum = +e.data.not_read_count
|
|
|
|
|
- })
|
|
|
|
|
- notify().then((e) => {
|
|
|
|
|
- that.notifyNum = +e.data.not_read_count
|
|
|
|
|
- })
|
|
|
|
|
- },
|
|
|
|
|
- navTo(url) {
|
|
|
|
|
- uni.navigateTo({
|
|
|
|
|
- url: url
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ methods: {}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
};
|
|
};
|
|
|
</script>
|
|
</script>
|