shareList.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <template>
  2. <view class="box">
  3. <template v-if="shareList.length > 0">
  4. <view class="meauList" v-for="item in shareList" :key="item.devId">
  5. <view class="menu-item">
  6. <view class="meanLeft">
  7. <text>分享人号码</text>
  8. </view>
  9. <view class="meanRight">
  10. <text>{{ item.sharerPhone }}</text></view
  11. >
  12. </view>
  13. <view class="menu-item">
  14. <view class="meanLeft">
  15. <text>设备名称</text>
  16. </view>
  17. <view class="meanRight">
  18. <text>{{ item.devName }}</text></view
  19. >
  20. </view>
  21. <view class="menu-item">
  22. <view class="meanLeft">
  23. <text>设备序列号</text>
  24. </view>
  25. <view class="meanRight">
  26. <text>{{ item.clientId }}</text></view
  27. >
  28. </view>
  29. <view class="menu-item">
  30. <view class="meanLeft">
  31. <text>分享时间</text>
  32. </view>
  33. <view class="meanRight">
  34. <text>{{ item.shareTime }}</text></view
  35. >
  36. </view>
  37. <view class="menu-item">
  38. <view class="meanLeft">
  39. <text>分享状态</text>
  40. </view>
  41. <view class="meanRight">
  42. <text v-if="item.state == 0" style="color: #7a5446"
  43. >待确认</text
  44. >
  45. <text v-if="item.state == 1" style="color: #22b85e"
  46. >已确认</text
  47. >
  48. <text v-if="item.state == 2" style="color: #ee3535"
  49. >已拒绝</text
  50. >
  51. </view>
  52. </view>
  53. <view class="menu-bottom" v-if="item.state == 0">
  54. <view class="meanLeft" @click="acceptDevice(item)"
  55. >授权</view
  56. >
  57. <view class="meanRight" @click="refuseDevice(item)"
  58. >拒绝</view
  59. >
  60. </view>
  61. </view>
  62. </template>
  63. </view>
  64. </template>
  65. <script>
  66. export default {
  67. data() {
  68. return {
  69. shareList: [],
  70. status: null,
  71. };
  72. },
  73. methods: {
  74. getShareList() {
  75. uni.showLoading({
  76. title: "加载中",
  77. });
  78. this.$http
  79. .post("wap/share/queryDevShare", {
  80. userId: uni.getStorageSync("userId"),
  81. state: null,
  82. })
  83. .then((res) => {
  84. uni.hideLoading();
  85. if (res.data.data) {
  86. this.shareList = res.data.data;
  87. if (this.shareList && this.status != null) {
  88. const hasStatusZero = this.shareList.some(
  89. (item) => item.state === 0
  90. );
  91. if (!hasStatusZero) {
  92. this.state = null;
  93. this.getShareList();
  94. }
  95. }
  96. }
  97. });
  98. },
  99. acceptDevice(item) {
  100. let shareConfirmParam = {
  101. devId: item.devId,
  102. sharedUserId: item.sharedUserId,
  103. state: 1,
  104. };
  105. this.$http
  106. .post("wap/share/Confirm", shareConfirmParam, {
  107. header: {
  108. "Content-Type": "application/json;charset=UTF-8",
  109. },
  110. })
  111. .then((res) => {
  112. if (res.data.code == 200) {
  113. uni.showToast({
  114. title: "授权成功",
  115. icon: "success",
  116. duration: 1500,
  117. });
  118. } else {
  119. uni.showToast({
  120. title: res.data.message,
  121. icon: "none",
  122. duration: 1500,
  123. });
  124. }
  125. this.getShareList();
  126. });
  127. },
  128. refuseDevice(item) {
  129. let shareConfirmParam = {
  130. devId: item.devId,
  131. sharedUserId: item.sharedUserId,
  132. state: 2,
  133. };
  134. this.$http
  135. .post("wap/share/Confirm", shareConfirmParam, {
  136. header: {
  137. "Content-Type": "application/json;charset=UTF-8",
  138. },
  139. })
  140. .then((res) => {
  141. if (res.data.code == 200) {
  142. uni.showToast({
  143. title: "已拒绝该设备",
  144. icon: "success",
  145. duration: 1500,
  146. });
  147. } else {
  148. uni.showToast({
  149. title: res.data.message,
  150. icon: "none",
  151. duration: 1500,
  152. });
  153. }
  154. this.getShareList();
  155. });
  156. },
  157. },
  158. onShow() {
  159. this.getShareList();
  160. },
  161. onPullDownRefresh() {
  162. this.getShareList();
  163. setTimeout(() => {
  164. uni.stopPullDownRefresh();
  165. }, 1000);
  166. },
  167. };
  168. </script>
  169. <style lang="less" scoped>
  170. // Main Styles
  171. .box {
  172. padding: 10rpx 18rpx;
  173. width: 100vw;
  174. height: 100vh;
  175. background: linear-gradient(180deg, #faede2 0%, #f4f4f4 100%);
  176. box-sizing: border-box;
  177. .meauList {
  178. width: 710rpx;
  179. margin: 18rpx auto;
  180. background: #fff;
  181. border-radius: 16rpx;
  182. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
  183. overflow: hidden;
  184. transition: all 0.3s ease;
  185. .menu-item {
  186. display: flex;
  187. align-items: center;
  188. justify-content: space-between;
  189. margin: 0 32rpx;
  190. padding: 32rpx 0;
  191. border-bottom: 1rpx solid #f0f0f0;
  192. &:last-of-type {
  193. border-bottom: none;
  194. }
  195. .meanLeft {
  196. flex: 1;
  197. color: #666;
  198. font-size: 28rpx;
  199. font-weight: 400;
  200. }
  201. .meanRight {
  202. flex: 1;
  203. text-align: right;
  204. color: #333;
  205. font-size: 28rpx;
  206. font-weight: 500;
  207. padding-left: 20rpx;
  208. }
  209. }
  210. .menu-bottom {
  211. display: flex;
  212. padding: 24rpx 32rpx;
  213. border-top: 1rpx solid #f0f0f0;
  214. .meanLeft,
  215. .meanRight {
  216. flex: 1;
  217. height: 80rpx;
  218. display: flex;
  219. align-items: center;
  220. justify-content: center;
  221. border-radius: 8rpx;
  222. font-size: 30rpx;
  223. font-weight: 500;
  224. transition: all 0.2s;
  225. &:active {
  226. opacity: 0.8;
  227. }
  228. }
  229. .meanLeft {
  230. background: #7b5245;
  231. color: white;
  232. margin-right: 16rpx;
  233. }
  234. .meanRight {
  235. background: fade(#ff4d4f, 10%);
  236. color: #ff4d4f;
  237. border: 1rpx solid fade(#ff4d4f, 30%);
  238. }
  239. }
  240. }
  241. }
  242. </style>