123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303 |
- import amap from '@/access/amap-wx.js';
- import permision from "@/access/wa-permission/permission.js"
- import webUrl from '../config.js';
- export default {
- onPageScroll(obj) {
- // console.log(obj)
- this.navFixed = (obj.scrollTop > 1)
- // console.log(this.navFixed)
- },
- computed: {
- barHeight() {
- const systemInfo = uni.getSystemInfoSync();
- return systemInfo.statusBarHeight
- },
- theme() {
- if (this.$store.state.baseSet && this.$store.state.baseSet.themeStyle) {
- return this.$store.state.baseSet.themeStyle.theme || 'red'
- } else {
- return 'red'
- }
- },
- primaryColor() {
- if (this.$store.state.baseSet && this.$store.state.baseSet.themeStyle) {
- return this.$store.state.baseSet.themeStyle.color_o
- } else {
- return '#FD463E'
- }
- },
- primaryJb() {
- if (this.$store.state.baseSet && this.$store.state.baseSet.themeStyle) {
- return `linear-gradient(315deg, ${this.$store.state.baseSet.themeStyle.color_o}, ${this.$store.state.baseSet.themeStyle.color_t})`
- } else {
- return `linear-gradient(315deg, #FD463E, #ff3883)`
- }
- },
- isUserAudit() {
- const userStatus = this.$store.state.userStatus
- if (userStatus.enableStatus === 4) {
- return false
- } else if (userStatus.status === 3) {
- return false
- } else if (userStatus.status === 1) {
- return false
- } else if (userStatus.status === 0) {
- return false
- } else {
- return true
- }
- }
- },
- data() {
- return {
- navFixed: false,
- isLoding: false
- // amapPlugin: null
- }
- },
- onLoad() {
- //在 onLoad 中初始化一个高德小程序 SDK 的实例对象。
- this.amapPlugin = new amap.AMapWX({
- key: webUrl.GDMap_key
- });
- },
- methods: {
- callphone(phone) {
- uni.makePhoneCall({
- phoneNumber: phone
- })
- },
- goPage(url, type) {
- if(!url) return
- let urlT = ''
- if (!['/pages/index/index', '/pages/cart/cart', '/pages/classification/cate'].includes(url)) {
- const arr = url.split('/')
- arr[1] = 'pagesT'
- urlT = arr.join('/')
- } else {
- if (['/pages/index/Seckill'].includes(url)) {
- urlT = 'pagesT/seckill/Seckill'
- } else {
- urlT = url
- }
- }
- if (type === 'none') {
- return
- }
- if (type === 'switchTab') {
- uni.switchTab({
- url: url
- })
- } else if (type === 'redirectTo') {
- uni.redirectTo({
- url: urlT
- })
- } else if (type === 'reLaunch') {
- uni.reLaunch({
- url: urlT
- })
- } else {
- uni.navigateTo({
- url: urlT
- })
- }
- },
- userAudit() {
- // 判断用户status状态 0:待补全 1:待审核 2:已审核 3:审核失败 4:审核中
- const userStatus = this.$store.state.userStatus
- if (userStatus.enableStatus === 4) {
- uni.clearStorageSync();
- uni.showModal({
- title: '账号已被禁用,您可以',
- content: '联系电话:' + userStatus.enterpriseMobile,
- confirmText: '联系客服',
- cancelText: '取消',
- success: res => {
- if (res.confirm) {
- uni.makePhoneCall({
- phoneNumber: userStatus.enterpriseMobile
- });
- } else {
- this.goPage('/pages/binding/bindInfo', 'reLaunch');
- }
- }
- });
- return;
- }
- // if (this.$store.state.baseSet.personnelReview === 5) {
- if (userStatus.status === 3) {
- // 说明资料不完善,跳转到完善资料的页面
- uni.showModal({
- title: '审核未通过审核,请重新修改资料',
- content: userStatus.auditFailReason || '',
- cancelText: '取消',
- confirmText: '修改资料',
- success: res => {
- if (res.confirm) {
- this.goPage('/pages/user/editUserInfo?token=' + this.$common.getToken());
- }
- }
- });
- } else if (userStatus.status === 1) {
- uni.showModal({
- title: '账号正在审核中,您可以',
- content: '联系电话:' + userStatus.enterpriseMobile,
- confirmText: '联系客服',
- cancelText: '取消',
- success: res => {
- if (res.confirm) {
- uni.makePhoneCall({
- phoneNumber: userStatus.enterpriseMobile
- });
- }
- }
- });
- } else if (userStatus.status === 0) {
- uni.showModal({
- title: '请完善信息后再进行操作',
- content: '商家需要对客户资料进行审核,请您完善信息后再次进行操作',
- confirmText: '完善信息',
- cancelText: '取消',
- success: res => {
- if (res.confirm) {
- this.goPage('/pages/user/editUserInfo');
- }
- }
- });
- }
- // }
- },
- backPage() {
- uni.navigateBack()
- },
- //授权
- getAuthorizeInfo() {
- this.getLocation();
- },
- // 再次获取授权 微信小程序
- // 当用户第一次拒绝后再次请求授权
- openConfirm() {
- // uni.showModal({
- // title: '请求授权当前位置',
- // content: '商品信息将无法正常显示,请确认授权',
- // success: res => {
-
- // if(res.confirm) {
- // this.isLoding = true
- // uni.openSetting({
- // success: reso => {
- // // if (!reso.authSetting['scope.userLocation']) {
- // // this.openConfirm();
- // // }
- // if (!reso.authSetting['scope.userFuzzyLocation']) {
- // this.openConfirm();
- // }
- // },
- // complete: () => {
- // this.isLoding = false
- // }
- // });
- // }
-
- // }
- // });
- },
- // 获取定位
- getLocation() {
- this.isLoding = true
- this.amapPlugin.getRegeo({
- success: data => {
- const proCity = ['北京市', '天津市', '上海市', '重庆市']
- this.isLoding = false
- // console.log('获取定位:', data)
- const provinceName = data[0].regeocodeData.addressComponent.province
- console.log('获取定位:', provinceName)
- const cityName = proCity.includes(provinceName) ? provinceName : data[0].regeocodeData
- .addressComponent.city
- const districtName = data[0].regeocodeData.addressComponent.district
- // const address = data[0].regeocodeData.addressComponent.township
- const address = data[0].desc || data[0].regeocodeData.addressComponent.streetNumber
- .street || data[0].regeocodeData
- .addressComponent.township;
- const location = {
- provinceName: provinceName,
- cityName: cityName,
- districtName: districtName,
- address: address
- };
- // console.log(123, location)
- this.$store.commit('commit_locationObj', {
- ...location,
- latitude: data[0].latitude,
- longitude: data[0].longitude
- });
- // this.getTemplate();
- },
- fail: err => {
- console.log('定位失败,用户拒绝定位', err);
- // 拒绝授权
- // #ifdef MP
- this.openConfirm();
- // #endif
- // #ifdef APP-PLUS
- if (plus.os.name == "iOS") {
- let result = permision.judgeIosPermission('location')
- if (!result) {
- this.judgeIosPermission('location')
- }
- } else {
- this.requestAndroidPermission('android.permission.ACCESS_FINE_LOCATION')
- }
- // #endif
- // console.log('你拒绝了授权,无法获得周边信息');
- }
- });
- },
- // 再次获取授权 安卓
- async requestAndroidPermission(permisionID) {
- let result = await permision.requestAndroidPermission(permisionID)
- if (result == 1) {
- strStatus = "已获得授权"
- } else {
- // uni.showToast({
- // title: '未获取到您的位置信息,商品数据将无法正常显示,请前往【设置->应用->权限管理->位置】确认授权位置信息',
- // duration: 10000,
- // icon: 'none'
- // });
- // 设置->隐私->定位服务中开启定位服务
- uni.showModal({
- title: '定位服务已关闭',
- content: '您需要打开定位权限,才可以获取商品信息,请前往【设置->应用->权限管理->位置】中开启定位服务',
- success: (res) => {
- if (res.confirm) {
- permision.gotoAppPermissionSetting()
- }
- }
- });
- }
- },
- // 再次获取授权 IOS
- judgeIosPermission(permisionID) {
- var result = permision.judgeIosPermission(permisionID)
- // var strStatus = (result) ? "已" : "未"
- if (!result) {
- uni.showModal({
- title: '定位服务已关闭',
- content: '您需要打开定位权限,才可以获取商品信息,请前往【设置->隐私->定位服务】中开启定位服务',
- success: (res) => {
- if (res.confirm) {
- permision.gotoAppPermissionSetting()
- }
- }
- });
- }
- }
- }
- }
|