艺易修小程序24.08.21
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.

354 lines
8.2 KiB

8 months ago
7 months ago
8 months ago
7 months ago
7 months ago
8 months ago
7 months ago
7 months ago
8 months ago
7 months ago
7 months ago
8 months ago
7 months ago
8 months ago
7 months ago
8 months ago
7 months ago
7 months ago
7 months ago
8 months ago
7 months ago
8 months ago
7 months ago
8 months ago
7 months ago
8 months ago
7 months ago
7 months ago
8 months ago
7 months ago
8 months ago
7 months ago
8 months ago
7 months ago
8 months ago
7 months ago
8 months ago
7 months ago
7 months ago
7 months ago
7 months ago
8 months ago
7 months ago
8 months ago
7 months ago
8 months ago
7 months ago
7 months ago
7 months ago
7 months ago
8 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
8 months ago
  1. <!-- 报修 -->
  2. <template>
  3. <view class="repair bx reserveSpace">
  4. <uv-form :model="form" :rules="rules" errorType="toast" ref="form" labelPosition="left" labelWidth="140">
  5. <uv-form-item label="楼栋" prop="building" borderBottom>
  6. <uv-input @focus="floorPickerOpen" placeholder="请选择楼层" v-model="form.building" border="none"
  7. :fontSize="30"></uv-input>
  8. <template v-slot:right>
  9. <uv-icon name="arrow-right"></uv-icon>
  10. </template>
  11. </uv-form-item>
  12. <uv-form-item label="室号" prop="room" borderBottom>
  13. <uv-input @focus="roomPickerOpen" placeholder="请选择室号" v-model="form.room" border="none"
  14. :fontSize="30"></uv-input>
  15. <template v-slot:right>
  16. <uv-icon name="arrow-right"></uv-icon>
  17. </template>
  18. </uv-form-item>
  19. <uv-form-item label="维修物品" prop="project" borderBottom>
  20. <uv-input v-model="form.project" placeholder="请填写维修物品的名称" :fontSize="30" border="none"></uv-input>
  21. </uv-form-item>
  22. <uv-form-item label="你的姓名" prop="name" borderBottom>
  23. <uv-input v-model="form.name" placeholder="请填写姓名" :fontSize="30" border="none"></uv-input>
  24. </uv-form-item>
  25. <uv-form-item label="你的电话" prop="phone" borderBottom>
  26. <uv-input v-model="form.phone" placeholder="请填写电话号" border="none" :fontSize="30"></uv-input>
  27. </uv-form-item>
  28. <uv-form-item label="描述说明" prop="context" borderBottom>
  29. <uv-textarea v-model="form.context" :height="140" :maxlength="200" textStyle="font-size : 30rpx" count
  30. placeholder="请输入描述说明"></uv-textarea>
  31. </uv-form-item>
  32. <uv-form-item label="照片" prop="image" labelPosition="top">
  33. <view class="image-list">
  34. <view @click="openImageMenu(index)" v-for="(item,index) in form.image" :key="index"
  35. class="image-item">
  36. <image :src="item" mode="widthFix"></image>
  37. </view>
  38. <view v-if="form.image.length < maxUpload" @click="uploadImage" class="upload">
  39. <uv-icon name="camera-fill" color="#3c9cff" size="50"></uv-icon>
  40. </view>
  41. </view>
  42. </uv-form-item>
  43. <uv-button type="primary" text="提交" shape="circle" customStyle="margin-top: 10px"
  44. @click="submitRepair"></uv-button>
  45. </uv-form>
  46. <!-- 报修地址选择(楼栋) -->
  47. <uv-picker ref="floorPicker" :columns="floorList" :itemHeight="100" :round="20" keyName="label" title="选择楼栋"
  48. @confirm="floorConfirm"></uv-picker>
  49. <!-- 报修地址选择(室号) -->
  50. <uv-picker ref="roomPicker" :columns="roomNumberList" :itemHeight="100" :round="20" keyName="label" title="选择室号"
  51. @confirm="roomConfirm"></uv-picker>
  52. <!-- 图片操作菜单 -->
  53. <uv-action-sheet ref="actionSheet" :actions="list" :round="20" cancelText="取消" title="图片操作"
  54. @select="selectImageSheet"> </uv-action-sheet>
  55. <!-- 隐私政策 -->
  56. <PrivacyAgreementPoup ref="showPrivacy"></PrivacyAgreementPoup>
  57. </view>
  58. </template>
  59. <script>
  60. import PrivacyAgreementPoup from "@/components/PrivacyAgreementPoup/PrivacyAgreementPoup.vue";
  61. export default {
  62. name: 'Repair',
  63. components: {
  64. PrivacyAgreementPoup
  65. },
  66. data() {
  67. return {
  68. form: {
  69. building: '', //楼栋
  70. room: '', //室号
  71. project: '', //项目
  72. phone: '', //手机号
  73. name: '', //姓名
  74. context: '', //简介
  75. image: []
  76. },
  77. rules: { //参数校验
  78. building: {
  79. type: 'string',
  80. required: true,
  81. message: '请选择楼栋',
  82. trigger: ['blur', 'change']
  83. },
  84. room: {
  85. type: 'string',
  86. required: true,
  87. message: '请选择室号',
  88. trigger: ['blur', 'change']
  89. },
  90. project: {
  91. type: 'string',
  92. required: true,
  93. message: '请填写维修物品',
  94. trigger: ['blur', 'change']
  95. },
  96. name: {
  97. type: 'string',
  98. required: true,
  99. message: '请填写姓名',
  100. trigger: ['blur', 'change']
  101. },
  102. phone: [{
  103. required: true,
  104. message: '请填写手机号',
  105. trigger: ['blur', 'change']
  106. }, {
  107. validator: (rule, value, callback) => {
  108. return uni.$uv.test.mobile(value);
  109. },
  110. message: '手机号格式错误',
  111. trigger: ['blur']
  112. }],
  113. context: {
  114. type: 'string',
  115. required: true,
  116. message: '请填写描述说明',
  117. trigger: ['blur', 'change']
  118. },
  119. image: {
  120. type: 'array',
  121. required: true,
  122. message: '请上传图片',
  123. trigger: ['blur', 'change']
  124. },
  125. },
  126. maxUpload: 4, //最大上传图片张数
  127. list: [ //图片操作菜单操作项
  128. {
  129. name: '查看图片',
  130. id: 0
  131. },
  132. {
  133. name: '删除图片',
  134. id: 1
  135. }
  136. ],
  137. currentIndex: undefined, //当前操作的图片索引
  138. floorList: [
  139. [{
  140. id: 0,
  141. label: '楼栋1'
  142. },
  143. {
  144. id: 1,
  145. label: '楼栋2'
  146. }
  147. ]
  148. ], //楼栋列表
  149. roomNumberList: [
  150. [{
  151. id: 0,
  152. label: 'A1001'
  153. },
  154. {
  155. id: 1,
  156. label: 'A1002'
  157. }
  158. ]
  159. ], //室号列表
  160. }
  161. },
  162. onShow() {
  163. if (wx.onNeedPrivacyAuthorization) {
  164. console.log('onNeedPrivacyAuthorization');
  165. wx.onNeedPrivacyAuthorization(resolve => {
  166. console.log('onNeedPrivacyAuthorization');
  167. this.resolvePrivacyAuthorization = resolve
  168. this.$refs.showPrivacy.init(resolve)
  169. })
  170. }
  171. setTimeout(() => {
  172. this.$refs.showPrivacy.init({})
  173. },2000)
  174. wx.getPrivacySetting({
  175. success: res => {
  176. console.log(res)
  177. if (res.needAuthorization) {
  178. }
  179. }
  180. })
  181. },
  182. onReady() {
  183. this.$refs.form.setRules(this.rules);
  184. },
  185. methods: {
  186. //上传图片
  187. uploadImage() {
  188. let self = this
  189. this.$Oss.ossUploadImage({
  190. success(res) {
  191. self.form.image.push(res)
  192. }
  193. })
  194. },
  195. //打开图片操作菜单
  196. openImageMenu(index) {
  197. this.currentIndex = index
  198. this.$refs.actionSheet.open();
  199. },
  200. //用户选择了图片操作选项
  201. selectImageSheet(imageSheet) {
  202. let {
  203. id
  204. } = imageSheet
  205. if (id) {
  206. this.deleteImageAsList()
  207. } else {
  208. this.viewImageAsList()
  209. }
  210. },
  211. //查看图片
  212. viewImageAsList() {
  213. this.$utils.previewImage({
  214. current: this.currentIndex,
  215. urls: this.form.images
  216. })
  217. },
  218. //删除图片
  219. deleteImageAsList() {
  220. this.form.images = this.form.images.filter((_, index) => {
  221. return index != this.currentIndex
  222. })
  223. },
  224. //用户选择了楼栋
  225. floorConfirm(floor) {
  226. this.form.building = floor.value[0].label
  227. },
  228. //打开选择楼栋
  229. floorPickerOpen() {
  230. this.$refs.floorPicker.open();
  231. },
  232. //用户选择了室号
  233. roomConfirm(floor) {
  234. this.form.room = floor.value[0].label
  235. },
  236. //打开选择室号
  237. roomPickerOpen() {
  238. this.$refs.roomPicker.open();
  239. },
  240. //提交报修
  241. submitRepair() {
  242. this.$refs.form.validate().then(res => {
  243. let images = this.form.image.join()
  244. this.$api('addSchoolOrder', {
  245. ...this.form,
  246. image: images
  247. }, res => {
  248. uni.showToast({
  249. icon: 'none',
  250. title: '申请报修成功'
  251. })
  252. if (res.code == 200) {
  253. this.cleanfrom()
  254. this.$refs.form.clearValidate();
  255. this.toRepairList()
  256. }
  257. })
  258. }).catch(errors => {})
  259. },
  260. //跳转到报修记录
  261. toRepairList() {
  262. uni.navigateTo({
  263. url: '/pages/repairList/repairList'
  264. })
  265. },
  266. //清除表单数据
  267. cleanfrom() {
  268. this.form = {
  269. building: '', //楼栋
  270. room: '', //室号
  271. project: '', //项目
  272. phone: '', //手机号
  273. name: '', //姓名
  274. context: '', //简介
  275. image: []
  276. }
  277. }
  278. }
  279. }
  280. </script>
  281. <style scoped>
  282. .bx {
  283. width: 96%;
  284. margin: 0rpx auto;
  285. }
  286. .repair-title {
  287. display: flex;
  288. align-items: center;
  289. justify-content: center;
  290. height: 100rpx;
  291. padding-top: 100rpx;
  292. }
  293. .repair-title text {
  294. font-size: 40rpx;
  295. font-weight: bold;
  296. height: 70rpx;
  297. border-bottom: 8rpx solid #3c9cff;
  298. }
  299. .image-list {
  300. width: 100%;
  301. display: flex;
  302. flex-wrap: wrap;
  303. padding-top: 20rpx;
  304. }
  305. .image-item,
  306. .upload {
  307. display: flex;
  308. align-items: center;
  309. justify-content: center;
  310. width: 24%;
  311. height: 174rpx;
  312. background: #f8f8f8;
  313. margin-left: 1%;
  314. border-radius: 15rpx;
  315. overflow: hidden;
  316. margin-bottom: 20rpx;
  317. }
  318. .image-item image {
  319. width: 100%;
  320. }
  321. </style>