index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <view v-if="showPage">
  3. <!-- <view class="top-fixed" :style="'height:'+systems.barHeight+'rpx;'">
  4. <view :style="'height: '+systems.ktxStatusHeight+'rpx;'"></view>
  5. <view class="ddflex">
  6. <view class="back ddflex"
  7. :style="'height: '+systems.navigationHeight+'rpx;line-height: '+systems.navigationHeight+'rpx;'"
  8. @click="toBack">
  9. <image src="../static/images/back_black.png" mode="aspectFit"></image>
  10. </view>
  11. <view class="fflex" style="text-align: center;margin-left: rpx;"></view>
  12. <view style="position: relative;">
  13. <image style="width: 48rpx;height: 48rpx;margin-right: 30rpx;" src="/static/images/more1.png"
  14. @click.stop="isShowAdd = !isShowAdd"></image>
  15. <view class="add-pop" v-if="isShowAdd">
  16. <view class="add-pop-before">
  17. <view class="add-pop-li ddflex"
  18. @click="jumpUrl('/material/shareRecord/shareRecord')">
  19. <image src="/static/images/m_zfjl.png"></image>
  20. <view>转发记录</view>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. <view :style="'height:'+systems.barHeight+'rpx;'"></view>
  28. <view class="ceng" v-if="isShowAdd" @click="isShowAdd = false"></view> -->
  29. <videoPreview v-if="isShowPreview" :material="detaile" :content="removeHtml(detaile.brief)" :src="detaile.params.video.playUrl" :product="detaile.params.product?detaile.params.product:null" @videoPreviewClose="videoPreviewClose" @videoPreviewClick="showShareVideo"></videoPreview>
  30. <!-- #ifdef H5 -->
  31. <view class="share-pop" @click="hideSharePop" v-if="isShowSharePop">
  32. <image src="../static/images/fx-tip1.png"></image>
  33. </view>
  34. <wx-share ref="wxshare" />
  35. <!-- #endif -->
  36. </view>
  37. </template>
  38. <script>
  39. const req = require('../../utils/request.js');
  40. const api = require('../../utils/api.js');
  41. const util = require('../../utils/util.js');
  42. var app = getApp();
  43. import videoPreview from '../components/videoPreview/index.vue';
  44. export default {
  45. components: {
  46. videoPreview
  47. },
  48. data() {
  49. return {
  50. systems: {},
  51. isTop: 0,
  52. isShowAdd: false,
  53. showPage:false,
  54. content: "",
  55. options:{},
  56. isShowShare: false,
  57. bottomPositon: '-100%',
  58. isShowPreview:false,
  59. previewIndex:0,
  60. isShowTs:false,
  61. code: '',
  62. rootCode: '',
  63. detaile:{},
  64. config:{},
  65. hideShare: true,
  66. isShowSharePop: false,
  67. };
  68. },
  69. async onLoad(options) {
  70. this.code = options.code;
  71. this.rootCode = options.rootCode
  72. this.getConfig()
  73. await this.getDetail();
  74. },
  75. onReachBottom: function() {},
  76. onShareAppMessage: async function(options) {
  77. var content = await this.onShareMessage();
  78. this.SEND_SHARE_FN()
  79. return content;
  80. },
  81. onReady() {
  82. // #ifdef H5
  83. var that = this;
  84. //初始化分享内容
  85. setTimeout(async function() {
  86. var shareContent = await that.onShareMessage();
  87. if (shareContent) {
  88. shareContent.path = window.location.origin + shareContent.path;
  89. }
  90. that.$refs.wxshare.init(shareContent);
  91. }, 4 * 1000);
  92. // #endif
  93. },
  94. methods: {
  95. toBack() {
  96. let pages = getCurrentPages();
  97. if (pages.length > 1) {
  98. uni.navigateBack()
  99. }else{
  100. uni.switchTab({
  101. url:'/pages/tabBar/index'
  102. })
  103. }
  104. },
  105. async onShareMessage(options) {
  106. let isSolution = '';
  107. let path = '';
  108. // #ifndef H5
  109. isSolution = req.env[req.env.NODE_ENV].isSolution;
  110. // #endif
  111. // #ifdef H5
  112. isSolution = false;
  113. // #endif
  114. let userInfo = req.getStorage('userInfo');
  115. if (isSolution) {
  116. path = '/share/home/index?appId=' + req.getStorage('appId') + '&userId=' + req.getStorage(
  117. 'userInfo').id;
  118. } else {
  119. path = '/martial/video/index'+'?code=' + this.code + '&rootCode=' + this.rootCode + '&isShare=' + true + '&appId=' + req
  120. .getStorage('appId');
  121. // console.log(!req.getStorage('userInfo').id);
  122. if (!userInfo.id) {} else {
  123. path += '&userId=' + userInfo.id;
  124. }
  125. path = this.SHARE_BEHAVIOR_FN({path:path,sendShare:false}).path
  126. }
  127. console.log({
  128. title: this.detaile.title,
  129. imageUrl: this.detaile.pic,
  130. path: path
  131. })
  132. return {
  133. title: this.detaile.title,
  134. imageUrl: this.detaile.pic,
  135. path: path
  136. };
  137. },
  138. showShare() {
  139. // console.log(11111,this.hideShare)
  140. // #ifdef H5
  141. this.hideShare = false;
  142. this.showSharePop();
  143. console.log('引导分享==')
  144. // #endif
  145. },
  146. showSharePop() {
  147. this.isShowSharePop = true;
  148. },
  149. hideSharePop() {
  150. this.isShowSharePop = false;
  151. },
  152. closePop(){
  153. this.isShowAdd = false
  154. },
  155. jumpUrl(url){
  156. this.isShowAdd = false
  157. uni.navigateTo({
  158. url:url
  159. })
  160. },
  161. getConfig() {
  162. req.getRequest('/api/config', {}, res => {
  163. this.config = res
  164. })
  165. },
  166. removeHtml(text) {
  167. text = text.replace(/\r\n/g, "<br>")
  168. text = text.replace(/\n/g, "<br>");
  169. text = text.replace(/↵/g, "<br>");
  170. return text
  171. },
  172. removeText(text) {
  173. text = text.replace(/<br\/>/g, "\r\n")
  174. text = text.replace(/<br>/g, "\r\n")
  175. return text
  176. },
  177. getDetail() {
  178. let that = this;
  179. let apiUrl = '/api/v3/material/library/detail';
  180. return new Promise((resolve,reject)=>{
  181. req.getRequest(apiUrl,{ code: that.code },async res => {
  182. that.detaile = res;
  183. that.showPage = true
  184. that.isShowPreview = true
  185. resolve();
  186. },true);
  187. })
  188. },
  189. videoPreviewClose(){
  190. // this.isShowPreview = false
  191. },
  192. showShareVideo(){
  193. this.showShare()
  194. this.bottomPositon = 0
  195. },
  196. hideShareVideo(){
  197. this.isShowShare = false
  198. this.bottomPositon = '-100%'
  199. },
  200. formatTime(time){
  201. let date = new Date(time.replace(/-/g,'/'))
  202. return util.formatTimeComm(date,'Y.M.D')
  203. },
  204. loadCodeParams(scene) {
  205. let _ts = this;
  206. return new Promise((resolve, reject) => {
  207. let form = {
  208. scene: scene
  209. };
  210. if (!scene) {
  211. resolve();
  212. return false;
  213. }
  214. req.getRequest('/api/code/params', form, data => {
  215. let res = JSON.parse(data.scene)
  216. for(let key in res){
  217. this.options[key] = res[key]
  218. }
  219. resolve(res);
  220. });
  221. });
  222. },
  223. },
  224. mounted() {
  225. const systemInfo = uni.getSystemInfoSync();
  226. // px转换到rpx的比例
  227. let pxToRpxScale = 750 / systemInfo.windowWidth;
  228. let systems = {
  229. ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
  230. navigationHeight: 44 * pxToRpxScale // 导航栏的高度
  231. };
  232. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  233. this.systems = systems;
  234. },
  235. };
  236. </script>
  237. <style>
  238. @import './index.css';
  239. </style>