index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <template>
  2. <view class="work-container">
  3. <!-- 轮播图 -->
  4. <uni-swiper-dot class="uni-swiper-dot-box" :info="data" :current="current" field="content">
  5. <swiper class="swiper-box" :current="swiperDotIndex" @change="changeSwiper">
  6. <swiper-item v-for="(item, index) in data" :key="index">
  7. <view class="swiper-item" @click="clickBannerItem(item)">
  8. <image :src="item.image" mode="aspectFill" :draggable="false" />
  9. </view>
  10. </swiper-item>
  11. </swiper>
  12. </uni-swiper-dot>
  13. <!-- 宫格组件 -->
  14. <uni-section title="工作台" type="line"></uni-section>
  15. <view class="grid-body">
  16. <uni-grid :column="3" :showBorder="false" >
  17. <uni-grid-item v-if="hasRole(['admin'])">
  18. <view class="grid-item-box" @click="goPage('user')">
  19. <u--image :showLoading="true" src="/static/images/icons/user.png" width="50rpx" height="50rpx" ></u--image>
  20. <text class="text">客户列表</text>
  21. </view>
  22. </uni-grid-item>
  23. <uni-grid-item v-if="hasRole(['companymgr'])">
  24. <view class="grid-item-box" @click="goPage('device')">
  25. <u--image :showLoading="true" src="/static/images/icons/device.png" width="50rpx" height="50rpx" ></u--image>
  26. <text class="text">设备列表</text>
  27. </view>
  28. </uni-grid-item>
  29. <uni-grid-item>
  30. <view class="grid-item-box" @click="goPage('wifi')">
  31. <u--image :showLoading="true" src="/static/images/icons/wifi.png" width="50rpx" height="50rpx" ></u--image>
  32. <text class="text">设备配网</text>
  33. </view>
  34. </uni-grid-item>
  35. <uni-grid-item v-if="hasRole(['admin'])">
  36. <view class="grid-item-box" @click="goPage('scan')">
  37. <u--image :showLoading="true" src="/static/images/icons/code.png" width="50rpx" height="50rpx" ></u--image>
  38. <text class="text">绑码激活</text>
  39. </view>
  40. </uni-grid-item>
  41. <uni-grid-item v-if="hasRole(['companymgr'])">
  42. <view class="grid-item-box" @click="scanCode()">
  43. <u--image :showLoading="true" src="/static/images/icons/scan.png" width="50rpx" height="50rpx" ></u--image>
  44. <text class="text">用户绑定</text>
  45. </view>
  46. </uni-grid-item>
  47. <uni-grid-item>
  48. <view class="grid-item-box" @click="watchDevice()">
  49. <u--image :showLoading="true" src="/static/images/icons/scan.png" width="50rpx" height="50rpx" ></u--image>
  50. <text class="text">查看设备</text>
  51. </view>
  52. </uni-grid-item>
  53. <uni-grid-item v-if="hasRole(['companymgr'])">
  54. <view class="grid-item-box" @click="goPage('alert')">
  55. <u--image :showLoading="true" src="/static/images/icons/alert.png" width="50rpx" height="50rpx" ></u--image>
  56. <text class="text">设备告警</text>
  57. </view>
  58. </uni-grid-item>
  59. <uni-grid-item v-if="hasRole(['companymgr'])">
  60. <view class="grid-item-box" @click="goPage('error')">
  61. <u--image :showLoading="true" src="/static/images/icons/error.png" width="50rpx" height="50rpx" ></u--image>
  62. <text class="text">异常列表</text>
  63. </view>
  64. </uni-grid-item>
  65. <uni-grid-item v-if="hasRole(['admin'])">
  66. <view class="grid-item-box" @click="goPage('reset')">
  67. <u--image :showLoading="true" src="/static/images/icons/reset.png" width="50rpx" height="50rpx" ></u--image>
  68. <text class="text">注销设备</text>
  69. </view>
  70. </uni-grid-item>
  71. </uni-grid>
  72. <u-modal :show="show" :title="dlgTitle" @cancel="cancel" :showCancelButton="true" @confirm="bingDevice" >
  73. <view class="slot-content">
  74. <view>设备名称:{{ scanDevice.deviceName }}</view>
  75. <view>产品名称:{{ scanDevice.productName }}</view>
  76. <view>设备编号:{{ scanDevice.serialNumber }}</view>
  77. <view>激活日期:{{ scanDevice.activeTime }}</view>
  78. </view>
  79. </u-modal>
  80. </view>
  81. </view>
  82. </template>
  83. <script>
  84. import authObj from '@/plugins/auth.js';
  85. import {getDevcieByQrcode,bingDeviceDept} from '@/api/device/device';
  86. import UImage from "../../uni_modules/uview-ui/components/u--image/u--image";
  87. export default {
  88. components: {UImage},
  89. data() {
  90. return {
  91. dlgTitle:"",
  92. current: 0,
  93. swiperDotIndex: 0,
  94. show:false,
  95. scanDevice:{},
  96. data: [{
  97. image: '/static/images/banner/banner01.jpg'
  98. },
  99. // {
  100. // image: '/static/images/banner/banner02.jpg'
  101. // },
  102. // {
  103. // image: '/static/images/banner/banner03.jpg'
  104. // }
  105. ]
  106. }
  107. },
  108. methods: {
  109. bingDevice(){
  110. this.show = false;
  111. bingDeviceDept(this.scanDevice).then(res=>{
  112. if(res.code == 200){
  113. this.$modal.showToast('操作成功')
  114. }else{
  115. this.$modal.showToast(res.msg);
  116. }
  117. })
  118. },
  119. cancel(){
  120. this.show = false;
  121. this.scanDevice = {};
  122. },
  123. clickBannerItem(item) {
  124. console.log();
  125. },
  126. hasRole(role){
  127. return authObj.authRoleAdmin(role);
  128. },
  129. changeSwiper(e) {
  130. this.current = e.detail.current
  131. },
  132. changeGrid(e) {
  133. this.$modal.showToast('模块建设中~')
  134. },
  135. watchDevice(){
  136. let self = this;
  137. uni.scanCode({
  138. success: function (res) {
  139. console.log('条码内容:' + res.result);
  140. getDevcieByQrcode(res.result).then(res=>{
  141. let device = res.data;
  142. if(!self.hasRole(['admin'])){
  143. if(device.deptId == null || device.deptId == 0){
  144. self.$modal.showToast('设备不存在或无权限')
  145. return;
  146. }
  147. }
  148. if(device != null){
  149. uni.navigateTo({
  150. url: '/pages/device/detail?id='+device.deviceId
  151. });
  152. }else{
  153. self.$modal.showToast('设备不存在或无权限')
  154. }
  155. });
  156. }
  157. });
  158. },
  159. scanCode(){
  160. let self = this;
  161. uni.scanCode({
  162. success: function (res) {
  163. console.log('条码内容:' + res.result);
  164. getDevcieByQrcode(res.result).then(res=>{
  165. let device = res.data;
  166. if(!device){
  167. self.$modal.showToast('未查到设备信息')
  168. }else{
  169. if(device.deptId != null){
  170. self.$modal.showToast('该设备已经绑定了用户')
  171. }else{
  172. self.dlgTitle = "绑定设备";
  173. self.scanDevice = device;
  174. self.show = true;
  175. }
  176. }
  177. });
  178. }
  179. });
  180. },
  181. goPage(path){
  182. if('device' == path){
  183. uni.navigateTo({
  184. url: '/pages/device/index'
  185. });
  186. }
  187. if('wifi' == path){
  188. uni.navigateTo({
  189. url: '/pages/wifi/index'
  190. });
  191. }
  192. if('scan' == path){
  193. uni.navigateTo({
  194. url: '/pages/device/scan'
  195. });
  196. }
  197. if('user' == path){
  198. uni.navigateTo({
  199. url: '/pages/user/index'
  200. });
  201. }
  202. if('alert' == path){
  203. uni.navigateTo({
  204. url: '/pages/device/alert'
  205. });
  206. }
  207. if('error' == path){
  208. uni.navigateTo({
  209. url: '/pages/device/error'
  210. });
  211. }
  212. if('reset' == path){
  213. uni.navigateTo({
  214. url: '/pages/device/reset/reset'
  215. });
  216. }
  217. }
  218. }
  219. }
  220. </script>
  221. <style lang="scss">
  222. /* #ifndef APP-NVUE */
  223. page {
  224. display: flex;
  225. flex-direction: column;
  226. box-sizing: border-box;
  227. background-color: #fff;
  228. min-height: 100%;
  229. height: auto;
  230. }
  231. view {
  232. font-size: 14px;
  233. line-height: inherit;
  234. }
  235. /* #endif */
  236. .text {
  237. text-align: center;
  238. font-size: 26rpx;
  239. margin-top: 10rpx;
  240. }
  241. .grid-item-box {
  242. flex: 1;
  243. /* #ifndef APP-NVUE */
  244. display: flex;
  245. /* #endif */
  246. flex-direction: column;
  247. align-items: center;
  248. justify-content: center;
  249. padding: 15px 0;
  250. }
  251. .uni-margin-wrap {
  252. width: 690rpx;
  253. width: 100%;
  254. ;
  255. }
  256. .swiper {
  257. height: 300rpx;
  258. }
  259. .swiper-box {
  260. height: 150px;
  261. }
  262. .swiper-item {
  263. /* #ifndef APP-NVUE */
  264. display: flex;
  265. /* #endif */
  266. flex-direction: column;
  267. justify-content: center;
  268. align-items: center;
  269. color: #fff;
  270. height: 300rpx;
  271. line-height: 300rpx;
  272. }
  273. @media screen and (min-width: 500px) {
  274. .uni-swiper-dot-box {
  275. width: 400px;
  276. /* #ifndef APP-NVUE */
  277. margin: 0 auto;
  278. /* #endif */
  279. margin-top: 8px;
  280. }
  281. .image {
  282. width: 100%;
  283. }
  284. }
  285. </style>