novice.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <template>
  2. <view>
  3. <view class="novice">
  4. <view class="novice-main">
  5. <view class="releat">
  6. <view class="novice-tip">
  7. <view>值守人员</view>
  8. </view>
  9. <view class="line"></view>
  10. </view>
  11. <view class="novice-tel flex">
  12. <view>
  13. <view class="flex" v-for="item in info.onDutyList" :key="item.tel">
  14. <view class="novice-tel-name ellipsis">{{item.name}}</view>
  15. <view class="novice-tel-name novice-tel-phone">{{item.tel}}</view>
  16. </view>
  17. </view>
  18. <image src="../../static/wx_noveic_tel.png" class="novice-tel-img" @click="callPhone"></image>
  19. </view>
  20. <view class="releat">
  21. <view class="novice-tip">
  22. <view>集控中心</view>
  23. </view>
  24. <view class="line"></view>
  25. </view>
  26. <view class="novice-tel flex">
  27. <view>
  28. <view class="novice-tel-name ellipsis">{{info.contactPerson}}</view>
  29. <view class="novice-tel-name novice-tel-phone no-ma">{{info.contactPhone}}</view>
  30. </view>
  31. <image src="../../static/wx_noveic_tel.png" class="novice-tel-img" @click="call"></image>
  32. </view>
  33. <view class="releat">
  34. <view class="novice-tip">
  35. <view>操作指南</view>
  36. </view>
  37. <view class="line"></view>
  38. </view>
  39. <video :src="info.videoUrl" class="novice-video"></video>
  40. <rich-text space="nbsp" :nodes="info.material" class="novice-rich"></rich-text>
  41. </view>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. export default {
  47. data() {
  48. return {
  49. info: null,
  50. stationCode: null
  51. }
  52. },
  53. onShow() {
  54. if (this.$storage.getJson("token") && this.stationCode) {
  55. this.getInfo()
  56. }
  57. },
  58. onLoad(option) {
  59. this.stationCode = option.stationCode || null
  60. //this.info.material = this.formatRichText(this.info.material)
  61. },
  62. methods: {
  63. getInfo() {
  64. uni.showLoading();
  65. this.$http.getexchangeGuide('ZL000003').then(res => {
  66. uni.hideLoading();
  67. if (res.code === 0) {
  68. const material = this.formatRichText(res.data.material)
  69. res.data.material = material
  70. this.info = res.data
  71. } else {
  72. this.$utils.msg(res.msg)
  73. }
  74. })
  75. },
  76. appendNodeLineStyle(html, nodeName, style) {
  77. const reg = new RegExp(`<${nodeName}.*?>`, 'ig')
  78. return html.replace(reg, match => {
  79. // 检测是否有 `style` 属性
  80. if (match.indexOf('style=') !== -1) {
  81. // 在原有的 `style` 属性后面加上新的行内样式
  82. return match.replace(/style="(.*?)"/, `style="${style}$1"`);
  83. } else {
  84. // 否则直接添加 `style` 属性和行内样式属性
  85. return match.replace(/<img/, `<img style="${style}"`);
  86. }
  87. })
  88. },
  89. formatRichText(html) {
  90. if (typeof html !== 'string') {
  91. html = ''
  92. }
  93. // 解决图片宽度不能自适应的问题
  94. html = this.appendNodeLineStyle(html, 'img', 'max-width:100%;height:auto;')
  95. // 解决 `p` 标签在后台有默认的上下外边距,到小程序里没有上下外边距的问题
  96. html = this.appendNodeLineStyle(html, 'p', 'max-width:100%;margin-block-start:1em;margin-block-end:1em;')
  97. // 解决微信小程序会忽略空白换行的问题
  98. html = html.replace(/&nbsp;/g, '\u00A0')
  99. return html
  100. },
  101. callPhone() {
  102. const _this = this
  103. const phoneNumber = this.info.onDutyList.map(item => {
  104. return item.tel
  105. })
  106. uni.showActionSheet({
  107. itemList: phoneNumber,
  108. success(res) {
  109. // console.log("reasss",res)
  110. phoneNumber.forEach((item, index) => {
  111. if (res.tapIndex == index) {
  112. uni.makePhoneCall({
  113. phoneNumber: item,
  114. success: function() {
  115. console.log('拨打电话成功' + item)
  116. },
  117. fail: function() {
  118. console.log('拨打电话失败')
  119. },
  120. })
  121. }
  122. })
  123. },
  124. fail(res) {
  125. // console.log("拨打电话失败")
  126. },
  127. })
  128. },
  129. call() {
  130. const that = this
  131. uni.makePhoneCall({
  132. phoneNumber: that.info.contactPhone,
  133. success: function() {
  134. console.log('拨打电话成功' + item)
  135. },
  136. fail: function() {
  137. console.log('拨打电话失败')
  138. },
  139. })
  140. }
  141. }
  142. }
  143. </script>
  144. <style lang="scss" scoped>
  145. .flex {
  146. display: flex;
  147. }
  148. .ellipsis {
  149. overflow: hidden; //超出的文本隐藏
  150. text-overflow: ellipsis; //溢出用省略号显示
  151. white-space: nowrap; // 默认不换行;
  152. }
  153. .novice {
  154. overflow: scroll;
  155. height: 100vh;
  156. width: 100%;
  157. background: #F7F8FA;
  158. }
  159. .novice-main {
  160. background: #fff;
  161. margin-top: 20rpx;
  162. padding: 30rpx;
  163. .releat {
  164. position: relative;
  165. .line {
  166. width: 585rpx;
  167. height: 0rpx;
  168. opacity: 1;
  169. border: 1rpx solid;
  170. border-image: linear-gradient(90deg, rgba(229, 230, 235, 1), rgba(229, 230, 235, 0)) 1 1;
  171. position: absolute;
  172. top: 0;
  173. left: 106rpx;
  174. z-index: 10;
  175. }
  176. }
  177. .novice-tip {
  178. width: 140rpx;
  179. height: 40rpx;
  180. background: #E5E6EB;
  181. -webkit-clip-path: polygon(100% 0, 130rpx 100%, 0 100%, 0 0);
  182. line-height: 40rpx;
  183. font-size: 26rpx;
  184. font-family: PingFang SC-Regular, PingFang SC;
  185. font-weight: 400;
  186. color: #1D2129;
  187. text-indent: 15rpx;
  188. margin-bottom: 30rpx;
  189. }
  190. .novice-tel {
  191. padding: 24rpx 30rpx;
  192. background: #F7F8FA;
  193. align-items: center;
  194. justify-content: space-between;
  195. margin-bottom: 30rpx;
  196. .novice-tel-name {
  197. font-size: 26rpx;
  198. font-family: PingFang SC-Regular, PingFang SC;
  199. font-weight: 400;
  200. color: #1D2129;
  201. line-height: 44rpx;
  202. max-width: 180rpx;
  203. }
  204. .novice-tel-phone {
  205. color: #4E5969;
  206. margin-left: 16rpx;
  207. }
  208. .no-ma {
  209. margin-left: 0;
  210. }
  211. .novice-tel-img {
  212. width: 226rpx;
  213. height: 80rpx;
  214. }
  215. }
  216. .novice-video {
  217. width: 100%;
  218. height: 518rpx;
  219. }
  220. .novice-rich {
  221. width: 100%;
  222. word-break: break-all;
  223. white-space: pre-warp;
  224. }
  225. }
  226. </style>