加油站付款小程序,打印小票
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.

270 lines
6.4 KiB

  1. <!-- 报修 -->
  2. <template>
  3. <view class="repair bx reserveSpace">
  4. <!-- <view class="repair-title">
  5. <text>申请报修</text>
  6. </view> -->
  7. <uv-form :model="form" :rules="rules" :useBeforeRead="true" ref="form" labelPosition="left" labelWidth="100">
  8. <uv-form-item label="楼栋" prop="form.building" borderBottom>
  9. <uv-input @focus="floorPickerOpen" placeholder="请选择楼层" v-model="form.building" border="none"
  10. :fontSize="30"></uv-input>
  11. <template v-slot:right>
  12. <uv-icon name="arrow-right"></uv-icon>
  13. </template>
  14. </uv-form-item>
  15. <uv-form-item label="室号" prop="form.room" borderBottom>
  16. <uv-input @focus="roomPickerOpen" placeholder="请选择室号" v-model="form.room" border="none"
  17. :fontSize="30"></uv-input>
  18. <template v-slot:right>
  19. <uv-icon name="arrow-right"></uv-icon>
  20. </template>
  21. </uv-form-item>
  22. <uv-form-item label="项目" prop="form.project" borderBottom>
  23. <uv-input v-model="form.project" placeholder="请填写项目" :fontSize="30" border="none"></uv-input>
  24. </uv-form-item>
  25. <uv-form-item label="姓名" prop="form.name" borderBottom>
  26. <uv-input v-model="form.name" placeholder="请填写姓名" :fontSize="30" border="none"></uv-input>
  27. </uv-form-item>
  28. <uv-form-item label="简介" prop="form.intro" borderBottom>
  29. <uv-textarea v-model="form.intro" :height="140" :maxlength="200" textStyle="font-size : 30rpx" count
  30. placeholder="请输入内容"></uv-textarea>
  31. </uv-form-item>
  32. <uv-form-item label="电话号" prop="form.name" borderBottom>
  33. <uv-input v-model="form.phone" placeholder="请填写电话号" border="none" :fontSize="30"></uv-input>
  34. </uv-form-item>
  35. <uv-form-item label="照片" prop="form.images" labelPosition="top">
  36. <view class="image-list">
  37. <view @click="openImageMenu(index)" v-for="(item,index) in form.images" :key="index"
  38. class="image-item">
  39. <image :src="item" mode="widthFix"></image>
  40. </view>
  41. <view v-if="form.images.length < maxUpload" @click="uploadImage" class="upload">
  42. <uv-icon name="camera-fill" color="#3c9cff" size="50"></uv-icon>
  43. </view>
  44. </view>
  45. </uv-form-item>
  46. <uv-button type="primary" text="提交" shape="circle" customStyle="margin-top: 10px"
  47. @click="submitRepair"></uv-button>
  48. </uv-form>
  49. <!-- 报修地址选择(楼栋) -->
  50. <uv-picker ref="floorPicker" :columns="floorList" :itemHeight="100" :round="20" keyName="label" title="选择楼栋"
  51. @confirm="floorConfirm"></uv-picker>
  52. <!-- 报修地址选择(室号) -->
  53. <uv-picker ref="roomPicker" :columns="roomNumberList" :itemHeight="100" :round="20" keyName="label" title="选择室号"
  54. @confirm="roomConfirm"></uv-picker>
  55. <!-- 图片操作菜单 -->
  56. <uv-action-sheet ref="actionSheet" :actions="list" :round="20" cancelText="取消" title="图片操作"
  57. @select="selectImageSheet"> </uv-action-sheet>
  58. <showPrivacyAgreement ref="showPrivacy">
  59. </showPrivacyAgreement>
  60. </view>
  61. </template>
  62. <script>
  63. import showPrivacyAgreement from '@/components/config/showPrivacyAgreement.vue'
  64. export default {
  65. name: 'Repair',
  66. components: {
  67. showPrivacyAgreement
  68. },
  69. data() {
  70. return {
  71. form: {
  72. building: '', //楼栋
  73. room: '', //室号
  74. project: '', //项目
  75. phone: '', //手机号
  76. name: '', //姓名
  77. intro: '', //简介
  78. images: []
  79. },
  80. rules: { //参数校验
  81. 'form.name': {
  82. type: 'string',
  83. required: true,
  84. message: '请填写姓名',
  85. trigger: ['blur', 'change']
  86. }
  87. },
  88. maxUpload: 4, //最大上传图片张数
  89. list: [ //图片操作菜单操作项
  90. {
  91. name: '查看图片',
  92. id: 0
  93. },
  94. {
  95. name: '删除图片',
  96. id: 1
  97. }
  98. ],
  99. currentIndex: undefined, //当前操作的图片索引
  100. floorList: [
  101. [{
  102. id: 0,
  103. label: '楼栋1'
  104. },
  105. {
  106. id: 1,
  107. label: '楼栋2'
  108. }
  109. ]
  110. ], //楼栋列表
  111. roomNumberList: [
  112. [{
  113. id: 0,
  114. label: 'A1001'
  115. },
  116. {
  117. id: 1,
  118. label: 'A1002'
  119. }
  120. ]
  121. ], //室号列表
  122. }
  123. },
  124. onShow() {
  125. if (wx.onNeedPrivacyAuthorization) {
  126. console.log('onNeedPrivacyAuthorization');
  127. wx.onNeedPrivacyAuthorization(resolve => {
  128. console.log('onNeedPrivacyAuthorization');
  129. // 需要用户同意隐私授权时
  130. // 弹出开发者自定义的隐私授权弹窗
  131. this.resolvePrivacyAuthorization = resolve
  132. this.$refs.showPrivacy.init(resolve)
  133. })
  134. }
  135. },
  136. methods: {
  137. //上传图片
  138. uploadImage() {
  139. let self = this
  140. this.$Oss.ossUploadImage({
  141. success(res) {
  142. self.form.images.push(res)
  143. }
  144. })
  145. },
  146. //打开图片操作菜单
  147. openImageMenu(index) {
  148. this.currentIndex = index
  149. this.$refs.actionSheet.open();
  150. },
  151. //用户选择了图片操作选项
  152. selectImageSheet(imageSheet) {
  153. let {
  154. id
  155. } = imageSheet
  156. if (id) {
  157. this.deleteImageAsList()
  158. } else {
  159. this.viewImageAsList()
  160. }
  161. },
  162. //查看图片
  163. viewImageAsList() {
  164. this.$utils.previewImage({
  165. current: this.currentIndex,
  166. urls: this.form.images
  167. })
  168. },
  169. //删除图片
  170. deleteImageAsList() {
  171. this.form.images = this.form.images.filter((_, index) => {
  172. return index != this.currentIndex
  173. })
  174. },
  175. //用户选择了楼栋
  176. floorConfirm(floor) {
  177. this.form.building = floor.value[0].label
  178. },
  179. //打开选择楼栋
  180. floorPickerOpen() {
  181. uni.hideKeyboard()
  182. this.$refs.floorPicker.open();
  183. },
  184. //用户选择了室号
  185. roomConfirm(floor) {
  186. this.form.room = floor.value[0].label
  187. },
  188. //打开选择室号
  189. roomPickerOpen() {
  190. uni.hideKeyboard()
  191. this.$refs.roomPicker.open();
  192. },
  193. //提交报修
  194. submitRepair() {
  195. console.log(this.form);
  196. },
  197. }
  198. }
  199. </script>
  200. <style scoped>
  201. .bx {
  202. width: 96%;
  203. margin: 0rpx auto;
  204. }
  205. .repair-title {
  206. display: flex;
  207. align-items: center;
  208. justify-content: center;
  209. height: 100rpx;
  210. padding-top: 100rpx;
  211. }
  212. .repair-title text {
  213. font-size: 40rpx;
  214. font-weight: bold;
  215. height: 70rpx;
  216. border-bottom: 8rpx solid #3c9cff;
  217. }
  218. .image-list {
  219. width: 100%;
  220. display: flex;
  221. flex-wrap: wrap;
  222. padding-top: 20rpx;
  223. }
  224. .image-item,
  225. .upload {
  226. display: flex;
  227. align-items: center;
  228. justify-content: center;
  229. width: 24%;
  230. height: 174rpx;
  231. background: #f8f8f8;
  232. margin-left: 1%;
  233. border-radius: 15rpx;
  234. overflow: hidden;
  235. margin-bottom: 20rpx;
  236. }
  237. .image-item image {
  238. width: 100%;
  239. }
  240. </style>