goPage.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. import amap from '@/access/amap-wx.js';
  2. import permision from "@/access/wa-permission/permission.js"
  3. import webUrl from '../config.js';
  4. export default {
  5. onPageScroll(obj) {
  6. // console.log(obj)
  7. this.navFixed = (obj.scrollTop > 1)
  8. // console.log(this.navFixed)
  9. },
  10. computed: {
  11. barHeight() {
  12. const systemInfo = uni.getSystemInfoSync();
  13. return systemInfo.statusBarHeight
  14. },
  15. theme() {
  16. if (this.$store.state.baseSet && this.$store.state.baseSet.themeStyle) {
  17. return this.$store.state.baseSet.themeStyle.theme || 'red'
  18. } else {
  19. return 'red'
  20. }
  21. },
  22. primaryColor() {
  23. if (this.$store.state.baseSet && this.$store.state.baseSet.themeStyle) {
  24. return this.$store.state.baseSet.themeStyle.color_o
  25. } else {
  26. return '#FD463E'
  27. }
  28. },
  29. primaryJb() {
  30. if (this.$store.state.baseSet && this.$store.state.baseSet.themeStyle) {
  31. return `linear-gradient(315deg, ${this.$store.state.baseSet.themeStyle.color_o}, ${this.$store.state.baseSet.themeStyle.color_t})`
  32. } else {
  33. return `linear-gradient(315deg, #FD463E, #ff3883)`
  34. }
  35. },
  36. isUserAudit() {
  37. const userStatus = this.$store.state.userStatus
  38. if (userStatus.enableStatus === 4) {
  39. return false
  40. } else if (userStatus.status === 3) {
  41. return false
  42. } else if (userStatus.status === 1) {
  43. return false
  44. } else if (userStatus.status === 0) {
  45. return false
  46. } else {
  47. return true
  48. }
  49. }
  50. },
  51. data() {
  52. return {
  53. navFixed: false,
  54. isLoding: false
  55. // amapPlugin: null
  56. }
  57. },
  58. onLoad() {
  59. //在 onLoad 中初始化一个高德小程序 SDK 的实例对象。
  60. this.amapPlugin = new amap.AMapWX({
  61. key: webUrl.GDMap_key
  62. });
  63. },
  64. methods: {
  65. callphone(phone) {
  66. uni.makePhoneCall({
  67. phoneNumber: phone
  68. })
  69. },
  70. goPage(url, type) {
  71. if(!url) return
  72. let urlT = ''
  73. if (!['/pages/index/index', '/pages/cart/cart', '/pages/classification/cate'].includes(url)) {
  74. const arr = url.split('/')
  75. arr[1] = 'pagesT'
  76. urlT = arr.join('/')
  77. } else {
  78. if (['/pages/index/Seckill'].includes(url)) {
  79. urlT = 'pagesT/seckill/Seckill'
  80. } else {
  81. urlT = url
  82. }
  83. }
  84. if (type === 'none') {
  85. return
  86. }
  87. if (type === 'switchTab') {
  88. uni.switchTab({
  89. url: url
  90. })
  91. } else if (type === 'redirectTo') {
  92. uni.redirectTo({
  93. url: urlT
  94. })
  95. } else if (type === 'reLaunch') {
  96. uni.reLaunch({
  97. url: urlT
  98. })
  99. } else {
  100. uni.navigateTo({
  101. url: urlT
  102. })
  103. }
  104. },
  105. userAudit() {
  106. // 判断用户status状态 0:待补全 1:待审核 2:已审核 3:审核失败 4:审核中
  107. const userStatus = this.$store.state.userStatus
  108. if (userStatus.enableStatus === 4) {
  109. uni.clearStorageSync();
  110. uni.showModal({
  111. title: '账号已被禁用,您可以',
  112. content: '联系电话:' + userStatus.enterpriseMobile,
  113. confirmText: '联系客服',
  114. cancelText: '取消',
  115. success: res => {
  116. if (res.confirm) {
  117. uni.makePhoneCall({
  118. phoneNumber: userStatus.enterpriseMobile
  119. });
  120. } else {
  121. this.goPage('/pages/binding/bindInfo', 'reLaunch');
  122. }
  123. }
  124. });
  125. return;
  126. }
  127. // if (this.$store.state.baseSet.personnelReview === 5) {
  128. if (userStatus.status === 3) {
  129. // 说明资料不完善,跳转到完善资料的页面
  130. uni.showModal({
  131. title: '审核未通过审核,请重新修改资料',
  132. content: userStatus.auditFailReason || '',
  133. cancelText: '取消',
  134. confirmText: '修改资料',
  135. success: res => {
  136. if (res.confirm) {
  137. this.goPage('/pages/user/editUserInfo?token=' + this.$common.getToken());
  138. }
  139. }
  140. });
  141. } else if (userStatus.status === 1) {
  142. uni.showModal({
  143. title: '账号正在审核中,您可以',
  144. content: '联系电话:' + userStatus.enterpriseMobile,
  145. confirmText: '联系客服',
  146. cancelText: '取消',
  147. success: res => {
  148. if (res.confirm) {
  149. uni.makePhoneCall({
  150. phoneNumber: userStatus.enterpriseMobile
  151. });
  152. }
  153. }
  154. });
  155. } else if (userStatus.status === 0) {
  156. uni.showModal({
  157. title: '请完善信息后再进行操作',
  158. content: '商家需要对客户资料进行审核,请您完善信息后再次进行操作',
  159. confirmText: '完善信息',
  160. cancelText: '取消',
  161. success: res => {
  162. if (res.confirm) {
  163. this.goPage('/pages/user/editUserInfo');
  164. }
  165. }
  166. });
  167. }
  168. // }
  169. },
  170. backPage() {
  171. uni.navigateBack()
  172. },
  173. //授权
  174. getAuthorizeInfo() {
  175. this.getLocation();
  176. },
  177. // 再次获取授权 微信小程序
  178. // 当用户第一次拒绝后再次请求授权
  179. openConfirm() {
  180. // uni.showModal({
  181. // title: '请求授权当前位置',
  182. // content: '商品信息将无法正常显示,请确认授权',
  183. // success: res => {
  184. // if(res.confirm) {
  185. // this.isLoding = true
  186. // uni.openSetting({
  187. // success: reso => {
  188. // // if (!reso.authSetting['scope.userLocation']) {
  189. // // this.openConfirm();
  190. // // }
  191. // if (!reso.authSetting['scope.userFuzzyLocation']) {
  192. // this.openConfirm();
  193. // }
  194. // },
  195. // complete: () => {
  196. // this.isLoding = false
  197. // }
  198. // });
  199. // }
  200. // }
  201. // });
  202. },
  203. // 获取定位
  204. getLocation() {
  205. this.isLoding = true
  206. this.amapPlugin.getRegeo({
  207. success: data => {
  208. const proCity = ['北京市', '天津市', '上海市', '重庆市']
  209. this.isLoding = false
  210. // console.log('获取定位:', data)
  211. const provinceName = data[0].regeocodeData.addressComponent.province
  212. console.log('获取定位:', provinceName)
  213. const cityName = proCity.includes(provinceName) ? provinceName : data[0].regeocodeData
  214. .addressComponent.city
  215. const districtName = data[0].regeocodeData.addressComponent.district
  216. // const address = data[0].regeocodeData.addressComponent.township
  217. const address = data[0].desc || data[0].regeocodeData.addressComponent.streetNumber
  218. .street || data[0].regeocodeData
  219. .addressComponent.township;
  220. const location = {
  221. provinceName: provinceName,
  222. cityName: cityName,
  223. districtName: districtName,
  224. address: address
  225. };
  226. // console.log(123, location)
  227. this.$store.commit('commit_locationObj', {
  228. ...location,
  229. latitude: data[0].latitude,
  230. longitude: data[0].longitude
  231. });
  232. // this.getTemplate();
  233. },
  234. fail: err => {
  235. console.log('定位失败,用户拒绝定位', err);
  236. // 拒绝授权
  237. // #ifdef MP
  238. this.openConfirm();
  239. // #endif
  240. // #ifdef APP-PLUS
  241. if (plus.os.name == "iOS") {
  242. let result = permision.judgeIosPermission('location')
  243. if (!result) {
  244. this.judgeIosPermission('location')
  245. }
  246. } else {
  247. this.requestAndroidPermission('android.permission.ACCESS_FINE_LOCATION')
  248. }
  249. // #endif
  250. // console.log('你拒绝了授权,无法获得周边信息');
  251. }
  252. });
  253. },
  254. // 再次获取授权 安卓
  255. async requestAndroidPermission(permisionID) {
  256. let result = await permision.requestAndroidPermission(permisionID)
  257. if (result == 1) {
  258. strStatus = "已获得授权"
  259. } else {
  260. // uni.showToast({
  261. // title: '未获取到您的位置信息,商品数据将无法正常显示,请前往【设置->应用->权限管理->位置】确认授权位置信息',
  262. // duration: 10000,
  263. // icon: 'none'
  264. // });
  265. // 设置->隐私->定位服务中开启定位服务
  266. uni.showModal({
  267. title: '定位服务已关闭',
  268. content: '您需要打开定位权限,才可以获取商品信息,请前往【设置->应用->权限管理->位置】中开启定位服务',
  269. success: (res) => {
  270. if (res.confirm) {
  271. permision.gotoAppPermissionSetting()
  272. }
  273. }
  274. });
  275. }
  276. },
  277. // 再次获取授权 IOS
  278. judgeIosPermission(permisionID) {
  279. var result = permision.judgeIosPermission(permisionID)
  280. // var strStatus = (result) ? "已" : "未"
  281. if (!result) {
  282. uni.showModal({
  283. title: '定位服务已关闭',
  284. content: '您需要打开定位权限,才可以获取商品信息,请前往【设置->隐私->定位服务】中开启定位服务',
  285. success: (res) => {
  286. if (res.confirm) {
  287. permision.gotoAppPermissionSetting()
  288. }
  289. }
  290. });
  291. }
  292. }
  293. }
  294. }