goPage.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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. },
  192. complete: () => {
  193. this.isLoding = false
  194. }
  195. });
  196. }
  197. }
  198. });
  199. },
  200. // 获取定位
  201. getLocation() {
  202. this.isLoding = true
  203. this.amapPlugin.getRegeo({
  204. success: data => {
  205. const proCity = ['北京市', '天津市', '上海市', '重庆市']
  206. this.isLoding = false
  207. // console.log('获取定位:', data)
  208. const provinceName = data[0].regeocodeData.addressComponent.province
  209. console.log('获取定位:', provinceName)
  210. const cityName = proCity.includes(provinceName) ? provinceName : data[0].regeocodeData
  211. .addressComponent.city
  212. const districtName = data[0].regeocodeData.addressComponent.district
  213. // const address = data[0].regeocodeData.addressComponent.township
  214. const address = data[0].desc || data[0].regeocodeData.addressComponent.streetNumber
  215. .street || data[0].regeocodeData
  216. .addressComponent.township;
  217. const location = {
  218. provinceName: provinceName,
  219. cityName: cityName,
  220. districtName: districtName,
  221. address: address
  222. };
  223. // console.log(123, location)
  224. this.$store.commit('commit_locationObj', {
  225. ...location,
  226. latitude: data[0].latitude,
  227. longitude: data[0].longitude
  228. });
  229. // this.getTemplate();
  230. },
  231. fail: err => {
  232. console.log('定位失败,用户拒绝定位', err);
  233. // 拒绝授权
  234. // #ifdef MP
  235. this.openConfirm();
  236. // #endif
  237. // #ifdef APP-PLUS
  238. if (plus.os.name == "iOS") {
  239. let result = permision.judgeIosPermission('location')
  240. if (!result) {
  241. this.judgeIosPermission('location')
  242. }
  243. } else {
  244. this.requestAndroidPermission('android.permission.ACCESS_FINE_LOCATION')
  245. }
  246. // #endif
  247. // console.log('你拒绝了授权,无法获得周边信息');
  248. }
  249. });
  250. },
  251. // 再次获取授权 安卓
  252. async requestAndroidPermission(permisionID) {
  253. let result = await permision.requestAndroidPermission(permisionID)
  254. if (result == 1) {
  255. strStatus = "已获得授权"
  256. } else {
  257. // uni.showToast({
  258. // title: '未获取到您的位置信息,商品数据将无法正常显示,请前往【设置->应用->权限管理->位置】确认授权位置信息',
  259. // duration: 10000,
  260. // icon: 'none'
  261. // });
  262. // 设置->隐私->定位服务中开启定位服务
  263. uni.showModal({
  264. title: '定位服务已关闭',
  265. content: '您需要打开定位权限,才可以获取商品信息,请前往【设置->应用->权限管理->位置】中开启定位服务',
  266. success: (res) => {
  267. if (res.confirm) {
  268. permision.gotoAppPermissionSetting()
  269. }
  270. }
  271. });
  272. }
  273. },
  274. // 再次获取授权 IOS
  275. judgeIosPermission(permisionID) {
  276. var result = permision.judgeIosPermission(permisionID)
  277. // var strStatus = (result) ? "已" : "未"
  278. if (!result) {
  279. uni.showModal({
  280. title: '定位服务已关闭',
  281. content: '您需要打开定位权限,才可以获取商品信息,请前往【设置->隐私->定位服务】中开启定位服务',
  282. success: (res) => {
  283. if (res.confirm) {
  284. permision.gotoAppPermissionSetting()
  285. }
  286. }
  287. });
  288. }
  289. }
  290. }
  291. }