You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

262 lines
7.6 KiB

1 week ago
  1. <template>
  2. <view class="container">
  3. <view class="lock-tips">
  4. <u-icon name="info-circle" color="#A94F20" size="12"></u-icon>
  5. <view style="margin-left: 3px;">
  6. 如搬家请及时修改门锁类型信息
  7. </view>
  8. </view>
  9. <view class="lock-info">
  10. <view class="address-info ">
  11. <u--form labelPosition="left" ref="uForm">
  12. <u-form-item required label="房屋类型" labelWidth="120" @click="showHouseType = true"
  13. :customStyle="{backgroundColor: '#fff', marginTop: '10px',padding: '10px 10px 10px 20px',borderRadius:'4px'}"
  14. ref="item1">
  15. <u--input v-model="lockInfo.houseType" disabled disabledColor="#ffffff" placeholder="请选择"
  16. placeholderStyle="text-align:right;color:#AAA" border="none" inputAlign="right"></u--input>
  17. <u-icon slot="right" name="arrow-right" color="#AAA"></u-icon>
  18. </u-form-item>
  19. <view style="background-color: #fff;border-radius:4px;margin-top: 10px;">
  20. <u-form-item required label="家门锁类型" labelWidth="120" @click="showLockType = true"
  21. :customStyle="{padding: '10px 10px 10px 20px'}"
  22. ref="item2">
  23. <u--input v-model="lockInfo.lockType" disabled disabledColor="#ffffff" placeholder="请选择"
  24. placeholderStyle="text-align:right;color:#AAA" border="none" inputAlign="right"></u--input>
  25. <u-icon slot="right" name="arrow-right" color="#AAA"></u-icon>
  26. </u-form-item>
  27. <!-- <view style="padding: 7px 17px; color: #AAAAAA;">
  28. 请在提交订单时选择钥匙交接方式
  29. </view> -->
  30. </view>
  31. <view v-if="false" style="background-color: #FFFCF2;border-radius:4px;margin-top: 10px;">
  32. <u-form-item required v-if="lockInfo.lockType=='钥匙或门禁卡'" label="如何交接钥匙"
  33. labelWidth="120" @click="showKeyHandover = true" borderBottom
  34. :customStyle="{padding: '10px 10px 10px 20px'}"
  35. ref="item3">
  36. <u--input v-model="lockInfo.keyHandover"
  37. disabled
  38. disabledColor="#ffffff"
  39. :customStyle="{backgroundColor:'#FFFCF2'}"
  40. placeholder="请选择"
  41. placeholderStyle="text-align:right;color:#AAA;" border="none" inputAlign="right"></u--input>
  42. <u-icon slot="right" name="arrow-right" color="#AAA"></u-icon>
  43. </u-form-item>
  44. <view v-if="lockInfo.lockType=='钥匙或门禁卡' && lockInfo.keyHandover=='藏于指定位置'"
  45. style="background-color: #FFFCF2; padding: 14px 17px;">
  46. <u-upload
  47. accept="video"
  48. :capture="['album','camera']"
  49. :fileList="fileList"
  50. @afterRead="afterRead"
  51. @delete="deletePic"
  52. :max-count="1"
  53. name="pet"
  54. width="60"
  55. height="60"
  56. >
  57. <image src="https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/video.png" style="width: 80px;height: 80px;"></image>
  58. </u-upload>
  59. </view>
  60. </view>
  61. </u--form>
  62. </view>
  63. </view>
  64. <u-picker :show="showHouseType" :showToolbar='false' :columns="houseTypeActions" @cancel="showHouseType = false" :immediateChange="true"
  65. @confirm="houseTypeSelect"></u-picker>
  66. <u-picker :show="showLockType" :showToolbar='false' :columns="lockTypeActions" @cancel="showLockType = false" :immediateChange="true"
  67. @confirm="lockTypeSelect"></u-picker>
  68. <u-picker :show="showKeyHandover" :showToolbar='false' :columns="keyHandoverActions" @cancel="showKeyHandover = false" :immediateChange="true"
  69. @confirm="keyHandoverSelect"></u-picker>
  70. <view class="address-save">
  71. <button class="address-save-btn" @click="save">保存</button>
  72. </view>
  73. </view>
  74. </template>
  75. <script>
  76. import {getLock,addLock,updateLock} from '@/api/system/lock.js'
  77. export default{
  78. data(){
  79. return{
  80. lockInfo:{
  81. id:"",
  82. houseType:"",
  83. lockType:"",
  84. keyHandover:"",
  85. keyStorageLocation:"",
  86. },
  87. fileList:[],
  88. showHouseType:false,
  89. showLockType:false,
  90. showKeyHandover:false,
  91. houseTypeActions:[['独户','合租']],
  92. lockTypeActions:[['钥匙或门禁卡','密码锁']],
  93. keyHandoverActions:[['闪送(直接送达至服务人员,自费往返费用)','存于快递柜(给与/归还)(上门前提供密码)','藏于指定位置']]
  94. }
  95. },
  96. mounted() {
  97. this.getLock();
  98. },
  99. methods:{
  100. // 删除图片
  101. deletePic(event) {
  102. this.fileList.splice(event.index, 1)
  103. },
  104. // 新增图片
  105. async afterRead(event) {
  106. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  107. let lists = [].concat(event.file)
  108. let fileListLen = this.fileList.length
  109. lists.map((item) => {
  110. this.fileList.push({
  111. ...item,
  112. status: 'uploading',
  113. message: ''
  114. })
  115. })
  116. for (let i = 0; i < lists.length; i++) {
  117. const result = await this.uploadFilePromise(lists[i].url)
  118. let item = this.fileList[fileListLen]
  119. this.fileList.splice(fileListLen, 1, Object.assign(item, {
  120. status: 'success',
  121. message: '',
  122. url: result
  123. }))
  124. fileListLen++
  125. }
  126. },
  127. uploadFilePromise(url) {
  128. return new Promise((resolve, reject) => {
  129. let a = uni.uploadFile({
  130. url: 'https://store-test.catmdogd.com/test-api/h5/oss/upload', // 仅为示例,非真实的接口地址
  131. filePath: url,
  132. name: 'file',
  133. formData: {
  134. user: 'test'
  135. },
  136. success: (res) => {
  137. setTimeout(() => {
  138. if(res&&res.data){
  139. let resData = JSON.parse(res.data);
  140. resolve(resData.url);
  141. }
  142. reject("上传失败");
  143. }, 1000)
  144. }
  145. });
  146. })
  147. },
  148. save(){
  149. if(!this.lockInfo.lockType){
  150. this.$modal.showToast('请选择门锁类型!')
  151. return;
  152. }
  153. if(this.lockInfo.lockType=='密码锁'){
  154. this.lockInfo.keyHandover = '';
  155. }
  156. if(this.lockInfo.keyHandover=='藏于指定位置'){
  157. this.lockInfo.keyStorageLocation = this.fileList[0].url;
  158. }else{
  159. this.lockInfo.keyStorageLocation = '';
  160. }
  161. let params =this.lockInfo;
  162. console.log(params);
  163. if(this.lockInfo.id){
  164. updateLock(params).then(res=>{
  165. if(res&&res.code==200){
  166. this.$modal.showToast('保存成功');
  167. }
  168. })
  169. } else{
  170. addLock(params).then(res=>{
  171. if(res&&res.code==200){
  172. this.$modal.showToast('保存成功');
  173. }
  174. })
  175. }
  176. },
  177. getLock() {
  178. getLock().then(res => {
  179. if (res.code == 200) {
  180. if(res.data){
  181. this.lockInfo=res.data
  182. if(res.data.keyStorageLocation){
  183. let url = res.data.keyStorageLocation
  184. this.fileList=[{url:url}]
  185. }
  186. }
  187. console.log(res)
  188. } else {
  189. this.$modal.showToast('获取门锁信息失败,请联系系统管理员!');
  190. }
  191. })
  192. },
  193. groupChange(n) {
  194. console.log('groupChange', n);
  195. this.lockInfo.isDefault=!this.lockInfo.isDefault
  196. },
  197. houseTypeSelect(e) {
  198. this.lockInfo.houseType = e.value[0];
  199. this.showHouseType=false;
  200. },
  201. lockTypeSelect(e) {
  202. this.lockInfo.lockType = e.value[0];
  203. this.showLockType=false;
  204. },
  205. keyHandoverSelect(e) {
  206. this.lockInfo.keyHandover = e.value[0];
  207. this.showKeyHandover=false;
  208. },
  209. }
  210. }
  211. </script>
  212. <style lang="scss">
  213. .container {
  214. position: relative;
  215. height: 100%;
  216. .address-save {
  217. background-color: #FFFFFF;
  218. padding: 10px 20px 40px;
  219. width: 100%;
  220. height: 90px;
  221. position: fixed;
  222. bottom: 0;
  223. z-index: 100;
  224. .address-save-btn {
  225. width: 100%;
  226. border-radius: 6px;
  227. background: #FFB13F;
  228. font-size: 16px;
  229. color: #FFFFFF;
  230. }
  231. }
  232. }
  233. .lock-info{
  234. padding: 0 10px;
  235. }
  236. .lock-info-item {
  237. background-color: #fff;
  238. margin-top: 10px;
  239. }
  240. .lock-tips{
  241. display: flex;
  242. justify-content: center;
  243. align-items: center;
  244. height: 38px;
  245. background-color: #fff1e3;
  246. color: #a94f20;
  247. }
  248. </style>