detail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. <template>
  2. <view class="container">
  3. <uni-nav-bar fixed :border="false" backgroundColor="#fff" :title="title" :statusBar="true"
  4. left-icon="left" @clickLeft="$navBack()">
  5. <!-- #ifndef MP-WEIXIN -->
  6. <template v-slot:right>
  7. <image class="righticon" src="/static/image/readall.png" mode="aspectFill" @click="handleReadAll"></image>
  8. <view class="rightText" @click="clickRight">{{rightText}}</view>
  9. </template>
  10. <!-- #endif -->
  11. </uni-nav-bar>
  12. <!-- #ifndef MP-WEIXIN -->
  13. <view class="allbtn-box" :style="{display: rightText=='取消' ? 'flex':'none'}">
  14. <view class="allbtn" @tap="handleAll()">全选</view>
  15. </view>
  16. <!-- #endif -->
  17. <!-- #ifndef APP-PLUS || H5 -->
  18. <view class="allbtn-box">
  19. <view class="allbtn" @tap="handleAll()" :style="{visibility: rightText=='取消' ? 'visible':'hidden'}">全选</view>
  20. <view style="display: flex;align-items: center;">
  21. <image class="righticon" src="/static/image/readall.png" mode="aspectFill" @click="handleReadAll"></image>
  22. <view class="rightText" @click="clickRight">{{rightText}}</view>
  23. </view>
  24. </view>
  25. <!-- #endif -->
  26. <view class="container-body">
  27. <mescroll-body :top="rightText=='取消' ? '100rpx' :'24rpx'" bottom="0" ref="mescrollRef" @init="mescrollInit" :down="downOption" :up="upOption" @down="downCallback" @up="upCallback">
  28. <view class="newslist" v-if="msgList&&msgList.length > 0">
  29. <view
  30. class="newslist-item border-line"
  31. :style="{paddingLeft: rightText=='取消' ? '54rpx':'0'}"
  32. v-for="(item,index) in msgList"
  33. :key="item.id">
  34. <view class="checkbox-icon" @click.stop="handleChoose(item)" :style="{display: rightText=='取消' ? 'flex':'none'}">
  35. <image src="@/static/images/pages_watch/icons/radio_default_icon.png" v-show="!item.checked"></image>
  36. <image src="@/static/images/pages_watch/icons/radio_choose_icon.png" v-show="item.checked"></image>
  37. </view>
  38. <view class="newslist-item-avatar">
  39. <image src="@/static/images/pages_watch/icons/watch_notification_icon.png" mode="aspectFill"></image>
  40. </view>
  41. <view class="newslist-item-msgbox" @click.stop="handleMsg(item)">
  42. <text class="newslist-item-time">{{item.dateTime}}</text>
  43. <view :class="item.appStatus == 1 ? 'newslist-item-msg':'newslist-item-msg isnew'"
  44. :style="{marginRight: item.extra == 'sos' ? '20rpx':'0'}">
  45. <view>
  46. <view>{{item.description}}</view>
  47. <!-- <view class="location" v-show="item.extra == 'sos'" @click="handleSOS(item)">{{item.location}}</view> -->
  48. </view>
  49. <view class="sosbox" v-show="item.extra == 'sos'" @click="handleSOS(item)">sos</view>
  50. <image class="phone_icon" v-show="item.extra == 'sos'" src="@/static/images/pages_watch/icons/phone_icon.png" mode="aspectFill" @click="getPhone"></image>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </mescroll-body>
  56. </view>
  57. <view class="footer" v-show="rightText=='取消'">
  58. <button class="savebtn" :loading="btnLoading" :disabled="btnLoading" @click="handleDel">
  59. 删 除
  60. </button>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  66. import { queryAlarmPageByStatus,setAlarmStatusById,deleteByIds,setAlarmStatusByDeviceId } from "@/api/pages_watch/message.js"
  67. import {getSim} from "@/api/pages_watch/index.js"
  68. export default {
  69. mixins: [MescrollMixin], // 使用mixin
  70. data() {
  71. return {
  72. // 获取设备平台
  73. platform: uni.getSystemInfoSync().platform,
  74. title: "",
  75. rightText: '设置',
  76. allbtnHeight: 0,
  77. statusBarHeight: uni.getSystemInfoSync().statusBarHeight + 'px',
  78. clientHeight: 0,
  79. btnLoading: false,
  80. queryParam: {
  81. deviceId: undefined,
  82. pageSize: 10,
  83. pageNum: 1,
  84. },
  85. msgList: [],
  86. mescroll:null,
  87. downOption: { //下拉刷新
  88. use:true,
  89. auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
  90. },
  91. upOption: {
  92. onScroll:false,
  93. use: true, // 是否启用上拉加载; 默认true
  94. page: {
  95. pae: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  96. size: 10 // 每页数据的数量,默认10
  97. },
  98. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  99. textNoMore:"已经到底了",
  100. empty: {
  101. icon:'https://cos.his.cdwjyyh.com/fs/20240423/cf4a86b913a04341bb44e34bb4d37aa2.png',
  102. tip: '暂无数据'
  103. }
  104. }
  105. }
  106. },
  107. onLoad(option) {
  108. this.title = option.title || ''
  109. uni.setNavigationBarTitle({
  110. title: this.title,
  111. });
  112. },
  113. methods: {
  114. handleReadAll() {
  115. uni.showModal({
  116. title: '',
  117. content: '确定标记所有未读消息为已读吗?',
  118. success: (res)=> {
  119. if (res.confirm) {
  120. this.setReadAll()
  121. }
  122. }
  123. });
  124. },
  125. setReadAll() {
  126. setAlarmStatusByDeviceId({deviceId: uni.getStorageSync("deviceId") || ''}).then(res=>{
  127. if(res.code == 200) {
  128. this.msgList = this.msgList.map(item=>({
  129. ...item,
  130. appStatus: 1,
  131. }))
  132. uni.showToast({
  133. title: res.msg,
  134. icon: 'none'
  135. })
  136. } else {
  137. uni.showToast({
  138. title: res.msg,
  139. icon: 'none'
  140. })
  141. }
  142. })
  143. },
  144. clickRight() {
  145. this.rightText = this.rightText == '设置' ? '取消':'设置'
  146. if(this.rightText=='设置') {
  147. this.allbtnHeight = 0
  148. this.msgList = this.msgList.map(item=>({
  149. ...item,
  150. checked: false,
  151. }))
  152. } else {
  153. this.allbtnHeight = 100
  154. }
  155. },
  156. handleChoose(item) {
  157. item.checked = !item.checked
  158. },
  159. handleDel() {
  160. const delList = this.msgList.filter(item=>item.checked).map(it=>it.id)
  161. if(delList && delList.length > 0) {
  162. this.btnLoading = true
  163. deleteByIds(delList).then(res=>{
  164. this.btnLoading = false
  165. if(res.code == 200) {
  166. this.rightText = '设置'
  167. this.allbtnHeight = 0
  168. this.mescroll.resetUpScroll()
  169. uni.showToast({
  170. title: '删除成功',
  171. icon: "none"
  172. })
  173. } else {
  174. uni.showToast({
  175. title: res.msg,
  176. icon: "none"
  177. })
  178. }
  179. }).catch(err=>{
  180. this.btnLoading = false
  181. })
  182. }
  183. },
  184. handleAll() {
  185. this.msgList = this.msgList.map(item=>({
  186. ...item,
  187. checked: true,
  188. }))
  189. },
  190. handleMsg(item) {
  191. if(item.appStatus == 0 ) {
  192. item.appStatus = 1
  193. }
  194. setAlarmStatusById([item.id]).then(res=>{
  195. if(res.code != 200) {
  196. item.appStatus = 0
  197. uni.showToast({
  198. title: res.msg,
  199. icon: "none"
  200. })
  201. }
  202. }).catch(()=>{
  203. item.appStatus = 0
  204. })
  205. if(item.extra == 'sos') {
  206. }
  207. },
  208. mescrollInit(mescroll) {
  209. this.mescroll = mescroll;
  210. },
  211. /*下拉刷新的回调 */
  212. downCallback() {
  213. this.mescroll.resetUpScroll()
  214. },
  215. /*上拉加载的回调*/
  216. upCallback(page) {
  217. //联网加载数据
  218. var that = this;
  219. this.queryParam.deviceId = uni.getStorageSync("deviceId") || ''
  220. this.queryParam.pageNum = page.num
  221. this.queryParam.pageSize = page.size
  222. queryAlarmPageByStatus(this.queryParam).then(res => {
  223. if(res.code==200){
  224. if (page.num == 1) {
  225. that.msgList = res.rows;
  226. } else {
  227. that.msgList = that.msgList.concat(res.rows);
  228. }
  229. that.mescroll.endBySize(res.rows.length, res.total);
  230. }else{
  231. uni.showToast({
  232. icon:'none',
  233. title: "请求失败",
  234. });
  235. that.msgList = null;
  236. that.mescroll.endErr();
  237. }
  238. });
  239. },
  240. // sos map
  241. handleSOS(item) {
  242. uni.navigateTo({
  243. url: '/pages_watch/message/sosMap?location='+item.location+'&dateTime=' +item.dateTime
  244. })
  245. },
  246. // sos phone
  247. getPhone() {
  248. getSim({deviceId: uni.getStorageSync("deviceId") || ''}).then(res=>{
  249. if(res.code == 200) {
  250. let phone = res.msg
  251. console.log(this.platform)
  252. //#ifdef APP-PLUS
  253. uni.makePhoneCall({
  254. phoneNumber: phone
  255. });
  256. //#endif
  257. //#ifndef APP-PLUS
  258. uni.makePhoneCall({
  259. phoneNumber: phone
  260. });
  261. //#endif
  262. } else {
  263. if(res.msg == "该设备未设置手机号!") {
  264. uni.showModal({
  265. content: res.msg,
  266. success: function (res) {
  267. if (res.confirm) {
  268. uni.navigateTo({
  269. url: "/pages_watch/index/equipment/deviceInfo"
  270. })
  271. }
  272. }
  273. });
  274. } else {
  275. uni.showToast({
  276. title: res.msg,
  277. icon: "none"
  278. })
  279. }
  280. }
  281. })
  282. }
  283. }
  284. }
  285. </script>
  286. <style lang="scss" scoped>
  287. @mixin u-flex($flexD, $alignI, $justifyC) {
  288. display: flex;
  289. flex-direction: $flexD;
  290. align-items: $alignI;
  291. justify-content: $justifyC;
  292. }
  293. .righticon {
  294. width: 48rpx;
  295. height: 48rpx;
  296. margin-right: 16rpx;
  297. }
  298. .rightText {
  299. font-family: PingFang SC, PingFang SC;
  300. font-weight: 400;
  301. font-size: 26rpx;
  302. color: #333333;
  303. }
  304. .location {
  305. font-family: PingFang SC, PingFang SC;
  306. font-weight: 400;
  307. font-size: 26rpx;
  308. color: #FF7700;
  309. }
  310. .allbtn-box {
  311. position: fixed;
  312. top: calc(var(--status-bar-height) + 88rpx);
  313. left: 0;
  314. z-index: 99;
  315. width: 100%;
  316. height: 100rpx;
  317. padding: 0 24rpx;
  318. box-sizing: border-box;
  319. background-color: #f7f7f7;
  320. @include u-flex(row,center,space-between);
  321. }
  322. .allbtn {
  323. display: inline-block;
  324. padding: 10rpx 24rpx;
  325. border-radius: 10rpx;
  326. background-color: #fff;
  327. font-family: PingFang SC, PingFang SC;
  328. font-weight: 400;
  329. font-size: 24rpx;
  330. color: #FF7700;
  331. }
  332. .sosbox {
  333. flex-shrink: 0;
  334. width: 100rpx;
  335. height: 100rpx;
  336. margin-left: 18rpx;
  337. margin-right: 10rpx;
  338. border-radius: 12rpx;
  339. font-family: DIN, DIN;
  340. font-weight: bolder;
  341. font-size: 40rpx;
  342. line-height: 90rpx;
  343. text-align: center;
  344. color: #fff;
  345. background: rgba(216,30,6,0.5);
  346. box-shadow: -12rpx -12rpx 16rpx 0 rgba(216,30,6, 1) inset,
  347. 14rpx 14rpx 24rpx 0 rgba(216,30,6, 0.6) inset;
  348. overflow: hidden;
  349. }
  350. .phone_icon {
  351. width: 47rpx;
  352. height: 47rpx;
  353. background-color: #fff;
  354. border-radius: 50%;
  355. overflow: hidden;
  356. position: absolute;
  357. right: -20rpx;
  358. top: 50%;
  359. transform: translateY(-50%);
  360. }
  361. .container-body {
  362. padding-bottom: calc(var(--window-bottom) + 24rpx);
  363. box-sizing: border-box;
  364. .checkbox-icon {
  365. position: absolute;
  366. top: 0;
  367. left: 0;
  368. height: 100%;
  369. @include u-flex(column,center,flex-start);
  370. padding-top: 64rpx;
  371. box-sizing: border-box;
  372. image {
  373. height: 30rpx;
  374. width: 30rpx;
  375. }
  376. }
  377. .newslist {
  378. margin: 0 24rpx 24rpx 24rpx;
  379. padding-bottom: 100rpx;
  380. &-item {
  381. width: 100%;
  382. overflow: hidden;
  383. margin-bottom: 40rpx;
  384. box-sizing: border-box;
  385. @include u-flex(row,flex-start, flex-start);
  386. font-family: PingFang SC, PingFang SC;
  387. font-weight: 400;
  388. font-size: 32rpx;
  389. color: #333;
  390. word-break: break-all;
  391. position: relative;
  392. &-avatar {
  393. flex-shrink: 0;
  394. border-radius: 50%;
  395. margin-right: 28rpx;
  396. margin-top: 38rpx;
  397. position: relative;
  398. image {
  399. width: 76rpx;
  400. height: 76rpx;
  401. }
  402. }
  403. &-msgbox {
  404. flex: 1;
  405. }
  406. &-time {
  407. width: 100%;
  408. margin-bottom: 8rpx;
  409. font-size: 28rpx;
  410. color: #999;
  411. text-align: center;
  412. display: inline-block;
  413. }
  414. &-msg {
  415. padding: 24rpx;
  416. box-sizing: border-box;
  417. border-radius: 16rpx;
  418. background-color: #fff;
  419. position: relative;
  420. @include u-flex(row,center, space-between);
  421. }
  422. .isnew {
  423. position: relative;
  424. &::after {
  425. content: "";
  426. height: 12rpx;
  427. width: 12rpx;
  428. border-radius: 50%;
  429. background-color: red;
  430. position: absolute;
  431. right: 0;
  432. top: 0;
  433. }
  434. }
  435. }
  436. }
  437. }
  438. .footer {
  439. width: 100%;
  440. padding: 50rpx 0;
  441. box-sizing: border-box;
  442. position: fixed;
  443. z-index: 99;
  444. bottom: var(--window-bottom);
  445. left: 0;
  446. .savebtn {
  447. width: 622rpx;
  448. height: 88rpx;
  449. line-height: 88rpx;
  450. border-radius: 44rpx 44rpx 44rpx 44rpx;
  451. background-color: #FF7700;
  452. font-family: PingFang SC, PingFang SC;
  453. font-weight: 500;
  454. font-size: 32rpx;
  455. color: #FFFFFF;
  456. &::after {
  457. border: none;
  458. }
  459. }
  460. }
  461. </style>