index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <view class="content">
  3. <view class="box">
  4. <web-view :src="url" @message="message"></web-view>
  5. </view>
  6. <!-- <view>12zf</view> -->
  7. </view>
  8. </template>
  9. <script>
  10. export default {
  11. data() {
  12. return {
  13. url: '',
  14. shopId:'',
  15. wxOpendata:'',
  16. logindata:'',
  17. id:'',
  18. }
  19. },
  20. onLoad(opt) {
  21. var that=this;
  22. this.wxOpendata=uni.getStorageSync("wxOpendata");
  23. this.logindata=uni.getStorageSync("logindata");
  24. //this.wxOpendata.code='39C455DB5CAF4FD4AE5F3F52EBA8ABD6'
  25. //opt.scene='E37BB2965A084534859DB351BA611AF9' //连锁二号
  26. //opt.scene='1B43BADDB6704B27B6C1604523287EAF' //连锁一号
  27. if(opt.scene){
  28. this.shopId=opt.scene;
  29. that.shopId=that.insertStr(that.shopId,8,"-");
  30. that.shopId=that.insertStr(that.shopId,13,"-");
  31. that.shopId=that.insertStr(that.shopId,18,"-");
  32. that.shopId=that.insertStr(that.shopId,23,"-");
  33. uni.setStorage({
  34. key: 'shopId',
  35. data: that.shopId,
  36. success: function () {
  37. }
  38. });
  39. if(this.shopId!=this.wxOpendata.shopID){
  40. uni.removeStorageSync('wxOpendata');
  41. this.wxOpendata=''
  42. }
  43. }
  44. if (opt.path) {
  45. //this.url = `${this.url}${options.path}`
  46. //this.url = opt.path
  47. console.log('options', opt)
  48. //console.log(opt)
  49. var url=opt.path.replace('$', '?')
  50. this.shopId=opt.shopId;
  51. if(this.shopId!=this.wxOpendata.shopID){
  52. if(opt.shareID){
  53. var webviewurl=url+'&shareID='+opt.shareID+'&type='+opt.type
  54. }else{
  55. var webviewurl=url+'&type='+opt.type
  56. }
  57. var testshopid='1B43BADD-B670-4B27-B6C1-604523287EAF'
  58. uni.setStorage({
  59. key: 'webviewurl',
  60. data: webviewurl,
  61. success: function () {
  62. uni.navigateTo({
  63. url:'../login/empower?shopId='+that.shopId
  64. })
  65. uni.removeStorageSync('wxOpendata');
  66. }
  67. });
  68. return false;
  69. }
  70. if(that.wxOpendata.code){
  71. if(opt.shareID){
  72. var webviewurl=url+"&codeapp="+that.wxOpendata.code+'&shareID='+opt.shareID+'&type='+opt.type+'&isDmsOpen='+that.wxOpendata.isDmsOpen+'&isMarketingOpen='+that.wxOpendata.isMarketingOpen
  73. }else{
  74. var webviewurl=url+"&codeapp="+that.wxOpendata.code+'&type='+opt.type+'&isDmsOpen='+that.wxOpendata.isDmsOpen+'&isMarketingOpen='+that.wxOpendata.isMarketingOpen
  75. }
  76. this.url = webviewurl;
  77. /* uni.setStorage({
  78. key: 'webviewurl',
  79. data: webviewurl,
  80. success: function () {
  81. uni.navigateTo({
  82. url:'../login/empower'
  83. })
  84. }
  85. }); */
  86. }else{
  87. if(opt.shareID){
  88. var webviewurl=url+'&shareID='+opt.shareID+'&type='+opt.type
  89. }else{
  90. var webviewurl=url+'&type='+opt.type
  91. }
  92. uni.setStorage({
  93. key: 'webviewurl',
  94. data: webviewurl,
  95. success: function () {
  96. uni.navigateTo({
  97. url:'../login/empower'
  98. })
  99. }
  100. });
  101. }
  102. console.log(url)
  103. }else{
  104. var newwebviewurl = uni.getStorageSync('webviewurl');
  105. if(newwebviewurl){
  106. newwebviewurl=newwebviewurl+"&codeapp="+that.wxOpendata.code+'&isDmsOpen='+that.wxOpendata.isDmsOpen+'&isMarketingOpen='+that.wxOpendata.isMarketingOpen
  107. this.url=newwebviewurl;
  108. uni.removeStorageSync('webviewurl');
  109. }else{
  110. uni.getLocation({
  111. type: 'gcj02',
  112. success: function (res) {
  113. console.log('当前位置的经度是:' + res.longitude);
  114. console.log('当前位置的纬度:' + res.latitude);
  115. if(opt.id){
  116. if(opt.quxiao==1){
  117. if(opt.type==6){
  118. that.url=that.$webURL+'carOwner/index?codeapp='+that.wxOpendata.code+'&lat='+res.latitude+'&lng='+res.longitude+'&isDmsOpen='+that.wxOpendata.isDmsOpen+'&isMarketingOpen='+that.wxOpendata.isMarketingOpen
  119. }else{
  120. that.url=that.$webURL+'order/'+opt.id+'?showBackHome=true&codeapp='+that.wxOpendata.code+'&lat='+res.latitude+'&lng='+res.longitude+'&isDmsOpen='+that.wxOpendata.isDmsOpen+'&isMarketingOpen='+that.wxOpendata.isMarketingOpen
  121. }
  122. }else{
  123. if(opt.type==6){
  124. that.url=that.$webURL+'paySuccessPinTuan?id='+opt.id+'&hideHeader=true&codeapp='+that.wxOpendata.code+'&lat='+res.latitude+'&lng='+res.longitude+'&isDmsOpen='+that.wxOpendata.isDmsOpen+'&isMarketingOpen='+that.wxOpendata.isMarketingOpen
  125. }else{
  126. that.url=that.$webURL+'paySuccess?orderId='+opt.id+'&hideHeader=true&codeapp='+that.wxOpendata.code+'&lat='+res.latitude+'&lng='+res.longitude+'&isDmsOpen='+that.wxOpendata.isDmsOpen+'&isMarketingOpen='+that.wxOpendata.isMarketingOpen
  127. }
  128. }
  129. }else{
  130. /* if(!that.wxOpendata.shopID||!that.logindata){
  131. uni.navigateTo({
  132. url:'../login/empower'
  133. })
  134. } */
  135. if(that.wxOpendata.code){
  136. //this.url='http://dms.32che.cn/#/carOwner/index?codeapp='+this.wxOpendata.code+ '&shopId='+this.wxOpendata.shopID
  137. that.url=that.$webURL+'carOwner/index?codeapp='+that.wxOpendata.code+ '&shopId='+that.wxOpendata.shopID+'&lat='+res.latitude+'&lng='+res.longitude+'&isDmsOpen='+that.wxOpendata.isDmsOpen+'&isMarketingOpen='+that.wxOpendata.isMarketingOpen
  138. }else{
  139. that.url=that.$webURL+'carOwner/index?codeapp=&shopId=&lat='+res.latitude+'&lng='+res.longitude
  140. }
  141. }
  142. },
  143. fail(err) {
  144. console.log(err)
  145. if(opt.id){
  146. if(opt.type==6){
  147. that.url=that.$webURL+'paySuccessPinTuan?id='+opt.id+'&hideHeader=true&codeapp='+that.wxOpendata.code+'&lat=&lng=&isDmsOpen='+that.wxOpendata.isDmsOpen+'&isMarketingOpen='+that.wxOpendata.isMarketingOpen
  148. }else{
  149. that.url=that.$webURL+'paySuccess?orderId='+opt.id+'&hideHeader=true&codeapp='+that.wxOpendata.code+'&lat=&lng=&isDmsOpen='+that.wxOpendata.isDmsOpen+'&isMarketingOpen='+that.wxOpendata.isMarketingOpen
  150. }
  151. }else{
  152. if(!that.wxOpendata.shopID){
  153. uni.navigateTo({
  154. url:'../login/empower'
  155. })
  156. }
  157. if(that.wxOpendata.code){
  158. //this.url='http://dms.32che.cn/#/carOwner/index?codeapp='+this.wxOpendata.code+ '&shopId='+this.wxOpendata.shopID
  159. that.url=that.$webURL+'carOwner/index?codeapp='+that.wxOpendata.code+ '&shopId='+that.wxOpendata.shopID+'&lat=""&lng=""'+'&isDmsOpen='+that.wxOpendata.isDmsOpen+'&isMarketingOpen='+that.wxOpendata.isMarketingOpen
  160. }
  161. }
  162. }
  163. });
  164. }
  165. }
  166. console.log(opt)
  167. //opt.id='3A9DBC40-D5D4-43A6-8ACA-5CF909771512'
  168. /* if(opt.shopId){
  169. this.url2='http://wx.32che.cn/weixin/authorize?path=/carOwner/index&isCarOwner=true&shopId='+opt.shopId
  170. } */
  171. //http://192.168.0.215:9588/#/carOwner/index?codeapp=D8E849B9EE0D4A07812BB0186E77B993&lat=36.68013&lng=117.06533
  172. var a = document.getElementsByClassName('uni-page-head-hd')[0]
  173. a.style.display = 'none';
  174. },
  175. mounted(){
  176. var a = document.getElementsByClassName('uni-page-head-hd')[0]
  177. a.style.display = 'none';
  178. },
  179. methods: {
  180. goUrl(){
  181. },
  182. insertStr(soure, start, newStr){
  183. return soure.slice(0, start) + newStr + soure.slice(start);
  184. },
  185. message(event){
  186. console.log(event);
  187. let { data } = event.mp.detail
  188. console.log('message', data)
  189. this.shareData = JSON.parse(data.pop())
  190. console.log(this.shareData)
  191. //this.shareData= event.mp.detail
  192. },
  193. },
  194. onShareAppMessage(){
  195. console.log(this.shareData)
  196. /* var share={
  197. url:this.shareData.path
  198. }
  199. var obj=JSON.stringify(share) */
  200. var newUrl=this.shareData.path.replace('?', '$')
  201. newUrl=newUrl+'&shopId='+this.wxOpendata.shopID
  202. console.log(newUrl)
  203. /*
  204. if (this.shareData) {
  205. path = shareData.path
  206. } */
  207. return {
  208. title:this.shareData.title,
  209. path: 'pages/index/index?path='+ encodeURI(newUrl),
  210. //path: 'pages/index/home?path='+ obj+'&id='+this.shareData.id+'&shareID='+this.shareData.shareID,
  211. imageUrl:this.shareData.img,
  212. desc:this.shareData.desc,
  213. success: function (res) {
  214. // 转发成功
  215. wx.showToast({
  216. title: "转发成功",
  217. icon: 'success',
  218. duration: 2000
  219. })
  220. },
  221. fail: function (res) {
  222. // 转发失败
  223. },
  224. }
  225. }
  226. }
  227. </script>
  228. <style>
  229. .content {
  230. /* display: flex;
  231. flex-direction: column;
  232. align-items: center;
  233. justify-content: center; */
  234. }
  235. .box{
  236. padding-bottom: env(safe-area-inset-bottom);
  237. }
  238. .logo {
  239. height: 200rpx;
  240. width: 200rpx;
  241. margin-top: 200rpx;
  242. margin-left: auto;
  243. margin-right: auto;
  244. margin-bottom: 50rpx;
  245. }
  246. .text-area {
  247. display: flex;
  248. justify-content: center;
  249. }
  250. .title {
  251. font-size: 36rpx;
  252. color: #8f8f94;
  253. }
  254. </style>