record.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. <template>
  2. <view>
  3. <view class="navbar">
  4. <view class="status_bar"></view>
  5. <view class="box">
  6. <view class="left" @click="navbar_back()">
  7. <uni-icons type="arrowleft" color="#fff" size="26"></uni-icons>
  8. </view>
  9. <view class="title">{{navbar_title}}</view>
  10. <view class="right" @click="navbar_more()">
  11. <uni-icons type="more-filled" color="#fff" size="24"></uni-icons>
  12. </view>
  13. </view>
  14. </view>
  15. <view class="status_bar"></view>
  16. <view style="height: 88rpx;"></view>
  17. <view class="pageItemList" v-for="(item,index) in pageItemList" :key="index">
  18. <!-- 纯文本模块 -->
  19. <view class="TEXT">
  20. <view v-if="item.pageRelation.businessType === 'TEXT'">
  21. <!-- 将内容所在父模块的索引保存到新数组 判断新数组中的索引值==循环的索引值时,让内容模块渲染(textVo_index[index_2] == index)保证了内容模块的排序问题 -->
  22. <view v-if="textVo_index[index_2] == index" v-for="(item_2,index_2) in textVo" :key="index_2">
  23. <e-text :textVo="textVo[index_2]"></e-text>
  24. </view>
  25. </view>
  26. </view>
  27. <!-- 图文模块 -->
  28. <view class="IMAGE_TEXT">
  29. <view v-if="item.pageRelation.businessType === 'IMAGE_TEXT'">
  30. <view v-if="imageText_index[index_2] == index" v-for="(item_2,index_2) in imageText" :key="index_2">
  31. <e-image-text :imageText="imageText[index_2]"></e-image-text>
  32. </view>
  33. </view>
  34. </view>
  35. <!-- 图集模块 -->
  36. <view class="PICTURE">
  37. <view v-if="item.pageRelation.businessType === 'PICTURE'">
  38. <view v-if="pictureList_index[index_2] == index" v-for="(item_2,index_2) in pictureList"
  39. :key="index_2">
  40. <e-picture :pictureList="pictureList[index_2]"></e-picture>
  41. </view>
  42. </view>
  43. </view>
  44. <!-- 文件模块 -->
  45. <view class="FILE">
  46. <view v-if="item.pageRelation.businessType === 'FILE'">
  47. <view v-if="fileList_index[index_2] == index" v-for="(item_2,index_2) in fileList" :key="index_2">
  48. <e-file :fileList="fileList[index_2]"></e-file>
  49. </view>
  50. </view>
  51. </view>
  52. <!-- 链接模块 -->
  53. <view class="LINKS">
  54. <view v-if="item.pageRelation.businessType === 'LINKS'">
  55. <view v-if="linksList_index[index_2] == index" v-for="(item_2,index_2) in linksList" :key="index_2">
  56. <e-link :linksList="linksList[index_2]" :mine_code="mine_code"></e-link>
  57. </view>
  58. </view>
  59. </view>
  60. <!-- 视频模块 -->
  61. <view class="VIDEO">
  62. <view v-if="item.pageRelation.businessType === 'VIDEO'">
  63. <view v-if="videoList_index[index_2] == index" v-for="(item_2,index_2) in videoList" :key="index_2">
  64. <e-video :videoList="videoList[index_2]"></e-video>
  65. </view>
  66. </view>
  67. </view>
  68. <!-- 设备铭牌模块 -->
  69. <view class="EQUIPMENT">
  70. <view v-if="item.pageRelation.businessType === 'EQUIPMENT'">
  71. <view v-if="equipmentList_index[index_2] == index" v-for="(item_2,index_2) in equipmentList"
  72. :key="index_2">
  73. <e-equipment :equipmentList="equipmentList[index_2]"></e-equipment>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. <!-- 浏览记录 -->
  79. <view v-if="browse.length != 0">
  80. <e-browse :browse="browse" :mine_code="mine_code" :pageId="pageId" :bgColor="bgColor"></e-browse>
  81. </view>
  82. </view>
  83. </template>
  84. <script>
  85. import {
  86. set_base_url
  87. } from '@/common/set_base_url.js'
  88. import Base64 from "@/common/js-base64.js"
  89. export default {
  90. data() {
  91. return {
  92. navbar_title: "",
  93. mine_code: "",
  94. base_url: "",
  95. // 二维码ID
  96. pageId: '',
  97. // 模块数组
  98. pageItemList: [],
  99. // 纯文本模块
  100. textVo: [],
  101. // 所在模块索引
  102. textVo_index: [],
  103. // base wenben
  104. textVo_dataContent: [],
  105. // 图文模块
  106. imageText: [],
  107. // 所在模块索引
  108. imageText_index: [],
  109. // base wenben
  110. imageText_dataContent: [],
  111. // 图集模块
  112. pictureList: [],
  113. // 所在模块索引
  114. pictureList_index: [],
  115. // 文件模块
  116. fileList: [],
  117. // 所在模块索引
  118. fileList_index: [],
  119. // 链接模块
  120. linksList: [],
  121. // 所在模块索引
  122. linksList_index: [],
  123. // 视频模块
  124. videoList: [],
  125. videoList_index: [],
  126. // 设备铭牌模块
  127. equipmentList: [],
  128. // 所在模块索引
  129. equipmentList_index: [],
  130. // 浏览记录
  131. browse: [],
  132. // 随即色
  133. bgColor: [],
  134. }
  135. },
  136. onLoad(option) {
  137. this.mine_code = option.mine_code
  138. // 根据矿编码切换首页接口不同的请求基础路径
  139. this.base_url = set_base_url(this.mine_code)
  140. // 获取二维码ID
  141. this.pageId = option.pageId
  142. // 获取二维码详情
  143. this.get_inner()
  144. // 获取浏览记录
  145. this.get_browse()
  146. },
  147. methods: {
  148. navbar_back() {
  149. uni.navigateBack()
  150. },
  151. navbar_more() {
  152. uni.showActionSheet({
  153. itemList: ['添加到常用'],
  154. success: (res) => {
  155. // console.log('选中了第' + (res.tapIndex + 1) + '个按钮');
  156. if (res.tapIndex == 0) {
  157. console.log(this.pageId)
  158. uni.showLoading({
  159. mask: true
  160. })
  161. this.$api.addCommonMenu({
  162. page_id: this.pageId,
  163. page_name: this.navbar_title
  164. }).then((res) => {
  165. uni.hideLoading()
  166. uni.showToast({
  167. icon: "none",
  168. title: "添加成功"
  169. })
  170. // console.log(res)
  171. })
  172. }
  173. },
  174. fail: (res) => {
  175. console.log(res.errMsg);
  176. }
  177. });
  178. },
  179. // 获取二维码详情
  180. get_inner() {
  181. uni.request({
  182. url: this.base_url + "/swagger/api/page/v1/detailPage?pageId=" + this.pageId +
  183. "&sourceType=&organizationIds=&userId=&userName=",
  184. success: (res) => {
  185. // console.log(res.data.data)
  186. const data = res.data.data
  187. // 设置页面标题
  188. uni.setNavigationBarTitle({
  189. title: data.page.title
  190. })
  191. this.navbar_title = data.page.title
  192. // 获取模块数组
  193. this.pageItemList = data.pageItemList
  194. // 判断模块属性
  195. for (let i = 0; i < data.pageItemList.length; i++) {
  196. if (data.pageItemList[i].pageRelation.businessType === 'TEXT') {
  197. // console.log("纯文本模块",i)
  198. // 内容模块数组
  199. this.textVo.push(data.pageItemList[i].textVo)
  200. // 保存内容所在父模块的索引
  201. this.textVo_index.push(i)
  202. // base64解码 替换原数组属性
  203. this.textVo_dataContent.push(data.pageItemList[i].textVo.dataContent)
  204. for (let i = 0; i < this.textVo_dataContent.length; i++) {
  205. this.textVo[i].dataContent = Base64.decode(this.textVo_dataContent[i])
  206. }
  207. // console.log(this.textVo_dataContent)
  208. // console.log(this.textVo)
  209. // console.log(this.textVo_index)
  210. } else if (data.pageItemList[i].pageRelation.businessType === 'IMAGE_TEXT') {
  211. // console.log("图文模块",i)
  212. // 图文模块
  213. this.imageText.push(data.pageItemList[i].imageText)
  214. // 保存内容所在父模块的索引
  215. this.imageText_index.push(i)
  216. // base64解码 替换原数组属性
  217. this.imageText_dataContent.push(data.pageItemList[i].imageText.dataContent)
  218. for (let i = 0; i < this.imageText_dataContent.length; i++) {
  219. this.imageText[i].dataContent = Base64.decode(this.imageText_dataContent[
  220. i])
  221. }
  222. } else if (data.pageItemList[i].pageRelation.businessType === 'PICTURE') {
  223. // console.log("图集模块",i)
  224. this.pictureList.push(data.pageItemList[i].pictureList)
  225. this.pictureList_index.push(i)
  226. } else if (data.pageItemList[i].pageRelation.businessType === 'FILE') {
  227. // console.log("文件模块",i)
  228. // 文件模块
  229. this.fileList.push(data.pageItemList[i].fileList)
  230. this.fileList_index.push(i)
  231. } else if (data.pageItemList[i].pageRelation.businessType === 'LINKS') {
  232. // console.log("链接模块",i)
  233. this.linksList.push(data.pageItemList[i].linksList)
  234. this.linksList_index.push(i)
  235. } else if (data.pageItemList[i].pageRelation.businessType === 'VIDEO') {
  236. // console.log("视频模块",i)
  237. // 视频模块
  238. this.videoList.push(data.pageItemList[i].videoList)
  239. this.videoList_index.push(i)
  240. } else if (data.pageItemList[i].pageRelation.businessType === 'EQUIPMENT') {
  241. // console.log("设备铭牌模块",i)
  242. // 设备铭牌模块
  243. this.equipmentList.push(data.pageItemList[i].equipmentList)
  244. this.equipmentList_index.push(i)
  245. } else if (data.pageItemList[i].pageRelation.businessType === 'RECORD') {
  246. // console.log("记录管理模块",i)
  247. }
  248. }
  249. }
  250. })
  251. },
  252. // 获取浏览记录
  253. get_browse() {
  254. // 添加浏览记录
  255. uni.request({
  256. method:"POST",
  257. url: this.base_url + "/swagger/api/pageuser/v1/addPageUser/",
  258. data:{
  259. createBy:"",
  260. createDate:"",
  261. id:"",
  262. userId: uni.getStorageSync('user').staff_num,
  263. pageId:this.pageId,
  264. status:"CREATE"
  265. },
  266. success: (res) => {
  267. // console.log(res)
  268. }
  269. })
  270. uni.request({
  271. url: this.base_url + "/swagger/api/pageuser/v1/getPageUserByPageId/" + this.pageId,
  272. success: (res) => {
  273. // console.log(res.data.data)
  274. this.browse = res.data.data
  275. this.browse.length = 3
  276. // console.log(this.browse)
  277. for (let i = 0; i < 3; i++) {
  278. // 获取随机色
  279. let r = parseInt(Math.random() * 256)
  280. let g = parseInt(Math.random() * 256)
  281. let b = parseInt(Math.random() * 256)
  282. // ES6 字符串拼接
  283. // this.bgColor = `rgba(${r},${g},${b},0.3)`
  284. let color = "rgba(" + r + "," + g + "," + b + "," + 0.3 + ")"
  285. // console.log(color)
  286. this.bgColor.push(color)
  287. }
  288. this.$forceUpdate()
  289. }
  290. })
  291. },
  292. },
  293. }
  294. </script>
  295. <style lang="scss">
  296. page {
  297. box-sizing: border-box;
  298. padding: 25rpx;
  299. margin-bottom: 90px;
  300. }
  301. .pageItemList {
  302. width: 700rpx;
  303. margin-bottom: 40rpx;
  304. }
  305. .bottom_btn {
  306. position: fixed;
  307. left: 0;
  308. bottom: 0;
  309. width: 750rpx;
  310. line-height: 60px;
  311. background-color: #009FE8;
  312. color: #FFFFFF;
  313. text-align: center;
  314. font-weight: 700;
  315. }
  316. // 标题栏
  317. .navbar {
  318. z-index: 999;
  319. width: 750rpx;
  320. position: fixed;
  321. top: 0;
  322. left: 0;
  323. background-color: #009FE8;
  324. color: #FFFFFF;
  325. .box {
  326. background-color: #009FE8;
  327. display: flex;
  328. justify-content: space-between;
  329. align-items: center;
  330. height: 88rpx;
  331. .left {
  332. width: 80rpx;
  333. height: 88rpx;
  334. line-height: 88rpx;
  335. text-align: center;
  336. }
  337. .title {
  338. font-size: 36rpx;
  339. height: 88rpx;
  340. line-height: 88rpx;
  341. font-weight: 500;
  342. }
  343. .right {
  344. width: 80rpx;
  345. height: 88rpx;
  346. line-height: 88rpx;
  347. text-align: left;
  348. }
  349. }
  350. }
  351. </style>