shareList.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. };
  71. },
  72. methods: {
  73. getShareList() {
  74. this.$http
  75. .get("wap/share/queryDevShare", {
  76. userId: uni.getStorageSync("userId"),
  77. })
  78. .then((res) => {
  79. if (res.data.data) {
  80. this.shareList = res.data.data;
  81. }
  82. })
  83. .catch((err) => {});
  84. },
  85. acceptDevice(item) {
  86. let shareConfirmParam = {
  87. devId: item.devId,
  88. sharedUserId: item.sharedUserId,
  89. state: 1,
  90. };
  91. this.$http
  92. .post("wap/share/Confirm", shareConfirmParam, {
  93. header: {
  94. "Content-Type": "application/json;charset=UTF-8",
  95. },
  96. })
  97. .then((res) => {
  98. if (res.data.code == 200) {
  99. uni.showToast({
  100. title: "授权成功",
  101. icon: "success",
  102. duration: 1500,
  103. });
  104. } else {
  105. uni.showToast({
  106. title: res.data.message,
  107. icon: "none",
  108. duration: 1500,
  109. });
  110. }
  111. this.getShareList();
  112. });
  113. },
  114. refuseDevice(item) {
  115. let shareConfirmParam = {
  116. devId: item.devId,
  117. sharedUserId: item.sharedUserId,
  118. state: 2,
  119. };
  120. this.$http
  121. .post("wap/share/Confirm", shareConfirmParam, {
  122. header: {
  123. "Content-Type": "application/json;charset=UTF-8",
  124. },
  125. })
  126. .then((res) => {
  127. if (res.data.code == 200) {
  128. uni.showToast({
  129. title: "已拒绝该设备",
  130. icon: "success",
  131. duration: 1500,
  132. });
  133. } else {
  134. uni.showToast({
  135. title: res.data.message,
  136. icon: "none",
  137. duration: 1500,
  138. });
  139. }
  140. this.getShareList();
  141. });
  142. },
  143. },
  144. onPullDownRefresh() {
  145. this.getShareList();
  146. setTimeout(() => {
  147. uni.stopPullDownRefresh();
  148. }, 1000);
  149. },
  150. onShow() {
  151. this.getShareList();
  152. },
  153. };
  154. </script>
  155. <style lang="less" scoped>
  156. // Main Styles
  157. .box {
  158. padding: 10rpx 18rpx;
  159. width: 100vw;
  160. height: 100vh;
  161. background: linear-gradient(180deg, #faede2 0%, #f4f4f4 100%);
  162. box-sizing: border-box;
  163. .meauList {
  164. width: 710rpx;
  165. margin: 18rpx auto;
  166. background: #fff;
  167. border-radius: 16rpx;
  168. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
  169. overflow: hidden;
  170. transition: all 0.3s ease;
  171. .menu-item {
  172. display: flex;
  173. align-items: center;
  174. justify-content: space-between;
  175. margin: 0 32rpx;
  176. padding: 32rpx 0;
  177. border-bottom: 1rpx solid #f0f0f0;
  178. &:last-of-type {
  179. border-bottom: none;
  180. }
  181. .meanLeft {
  182. flex: 1;
  183. color: #666;
  184. font-size: 28rpx;
  185. font-weight: 400;
  186. }
  187. .meanRight {
  188. flex: 1;
  189. text-align: right;
  190. color: #333;
  191. font-size: 28rpx;
  192. font-weight: 500;
  193. padding-left: 20rpx;
  194. }
  195. }
  196. .menu-bottom {
  197. display: flex;
  198. padding: 24rpx 32rpx;
  199. border-top: 1rpx solid #f0f0f0;
  200. .meanLeft,
  201. .meanRight {
  202. flex: 1;
  203. height: 80rpx;
  204. display: flex;
  205. align-items: center;
  206. justify-content: center;
  207. border-radius: 8rpx;
  208. font-size: 30rpx;
  209. font-weight: 500;
  210. transition: all 0.2s;
  211. &:active {
  212. opacity: 0.8;
  213. }
  214. }
  215. .meanLeft {
  216. background: #7b5245;
  217. color: white;
  218. margin-right: 16rpx;
  219. }
  220. .meanRight {
  221. background: fade(#ff4d4f, 10%);
  222. color: #ff4d4f;
  223. border: 1rpx solid fade(#ff4d4f, 30%);
  224. }
  225. }
  226. }
  227. }
  228. </style>