goPage.js 8.0 KB

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