Merge branch 'test'

This commit is contained in:
LuoShijie
2023-11-15 21:01:07 +08:00
21 changed files with 798 additions and 358 deletions

View File

@@ -6,13 +6,32 @@
<view class="grid-text">{{ item.text }}</view>
</u-grid-item>
</u-grid>
<u-modal :show="showM" showCancelButton closeOnClickOverlay="false" confirmText="是" cancelText="否"
@confirm="confirm" @cancel="cancel">
<view>
<view>{{mobile}}</view>
<text>是否拨打客服电话</text>
</view>
</u-modal>
<view>
<u-overlay :show="!isLoad">
<login @success="reOnLoad()" @fail="failToLoad()"></login>
</u-overlay>
</view>
</view>
</template>
<script>
import login from 'pages/my/login/login'
export default {
components: {
login
},
data() {
return {
showM: false,
mobile: '',
isLoad: true,
navItems: [{
icon: "/static/navbar/sy_icon_zrxx.png",
text: "转让信息",
@@ -46,7 +65,7 @@
{
icon: "/static/navbar/sy_icon_zmhb.png",
text: "招募合伙",
url:'/pages/Partnerships/Partnerships'
url: '/pages/Partnerships/Partnerships'
},
{
icon: "/static/navbar/sy_icon_lxwm.png",
@@ -56,21 +75,64 @@
]
};
},
created() {
this.getCsTel()
},
methods: {
reOnLoad() {
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
this.$toast.warn('登录失败请重试')
this.isLoad = false
return
}
this.isLoad = true
},
failToLoad() {
uni.reLaunch({
url: '/pages/index/index'
})
},
confirm() {
this.showM = false
let phone = this.mobile
phone = phone.toString()
uni.makePhoneCall({
phoneNumber: phone,
success: function() {
console.log('拨打电话成功');
},
fail() {
console.log('打电话失败了');
}
})
},
cancel() {
this.showM = false
},
getCsTel() {
this.$api.getCsTel().then(res => {
console.log(res.data);
if (res.data.data) {
this.mobile = res.data.data.kf_phone
}
}).finally(_ => {})
},
handleItemClick(index) {
// 跳转页面
if (index >= 0 && index <= 6) {
if (index == 4 || index == 6) {
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
this.isLoad = false
return
}
this.isLoad = true
}
uni.navigateTo({
url: this.navItems[index].url
})
}else if (index == 7) {
uni.makePhoneCall({
phoneNumber: '123456789',
success: (result) => {},
fail: (error) => {}
})
} else if (index == 7) {
this.showM = true
}
}
}
};

View File

@@ -27,6 +27,7 @@
import HomeNoticeBar from "./HomeMainContent/HomeNoticeBar.vue"
import HomeNavCard from "./HomeMainContent/HomeNavCard.vue"
import Statistics from "./HomeMainContent/Statistics.vue"
import QQMapWX from "@/utils/qqmap-wx-jssdk.min.js"
export default {
components: {
HomeNavCard,
@@ -45,11 +46,13 @@
this.getBanner()
this.getNotice()
this.getStat()
this.open()
},
methods: {
getBanner(){
this.$api.getBanner().then(res=>{
this.swiperList = res.data.data.map(item=>item.img)
console.log('轮播图',res.data.data);
this.swiperList = res.data.data.map(item=>this.$api.imgUrl+item.img)
})
},
getNotice(){
@@ -62,10 +65,100 @@
this.statNum = res.data.data
console.log(res.data.data);
})
},
getRegionList() {
var that = this
uni.request({
url: 'https://apis.map.qq.com/ws/district/v1/getchildren?id=' + uni.getStorageSync('city_code') + '&key=' +
that.$api.key,
success(res) {
uni.setStorageSync('regionList', JSON.stringify(res.data.result[0].map(item => item.fullname)));
},
fail(err) {
console.log('请求区域失败:', err);
}
})
},
getUserLocation() {
var that = this
let qqmapsdk = new QQMapWX({
key: that.$api.key
});
uni.getFuzzyLocation({
type: 'wgs84',
success(res) {
console.log('res.latitude', res.latitude);
console.log('res.longitude', res.longitude);
qqmapsdk.reverseGeocoder({
location: {
latitude: res.latitude,
longitude: res.longitude
},
success: (re) => {
console.log("解析地址成功", re);
console.log(re.result.ad_info.city);
console.log(re.result.ad_info.district);
let city = re.result.ad_info.city
let district = re.result.ad_info.district
console.log('city-code',re.result.ad_info.city_code.substring(3));
uni.setStorageSync('city_code', re.result.ad_info.city_code.substring(3));
uni.setStorageSync('city', city.slice(0, 2));
uni.setStorageSync('district', district);
that.getRegionList()
// that.position = city.slice(0, 2) + district.slice(0, 2)
},
fail: (re) => {
console.log(re, '失败信息');
}
})
},
fail(err) {
console.log("获取经纬度失败", err);
},
});
},
//提示用户开启定位服务
open() {
var that = this
uni.getSetting({
success: function (res) {
if (res.authSetting['scope.userFuzzyLocation']) {
console.log('用户已经授权定位权限');
} else {
console.log('用户未授权定位权限');
uni.authorize({
scope: 'scope.userFuzzyLocation',
success: function() {
console.log('授权成功');
that.getUserLocation()
},
fail: function() {
console.log('授权失败');
uni.showModal({
content: '检测到您没打开获取信息功能权限,是否去设置打开?',
confirmText: "确认",
cancelText: '取消',
success: (res) => {
if (res.confirm) {
uni.openSetting({
success: (res) => {
console.log(res);
that.getUserLocation();
}
})
} else {
console.log('取消');
return false;
}
}
})
return false;
}
})
}
}
});
}
},
computed: {
}
}
</script>