酒店桌布为微信小程序
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.

168 lines
3.4 KiB

6 months ago
5 months ago
6 months ago
  1. <template>
  2. <view class="form">
  3. <view class="shopName">
  4. <view>物品分类</view>
  5. <view class="list">
  6. <view :class="{act : form.categoryId == item.id}" @click="form.categoryId = item.id" :key="index"
  7. v-for="(item, index) in category">
  8. {{ item.name }}
  9. </view>
  10. </view>
  11. </view>
  12. <view class="shopName">
  13. <view>物品照片</view>
  14. <view>
  15. <uv-upload :fileList="fileList" :maxCount="1" width="180rpx"
  16. height="180rpx" multiple
  17. @afterRead="afterRead" @delete="deleteImage">
  18. <image src="../../static/help/uploading.png" mode="aspectFill"
  19. style="width: 180rpx;height: 180rpx;" />
  20. </uv-upload>
  21. </view>
  22. </view>
  23. <view class="shopName">
  24. <view>物品名称</view>
  25. <view>
  26. <input v-model="form.name" placeholder="请输入物品名称" clearable></input>
  27. </view>
  28. </view>
  29. <view class="shopName">
  30. <view>物品长度CM</view>
  31. <view>
  32. <input v-model="form.length" type="number" placeholder="请输入物品长度" clearable></input>
  33. </view>
  34. </view>
  35. <view class="shopName">
  36. <view>物品宽度CM</view>
  37. <view>
  38. <input v-model="form.wide" type="number" placeholder="请输入物品宽度" clearable></input>
  39. </view>
  40. </view>
  41. <view class="shopName">
  42. <view>物品数量</view>
  43. <view>
  44. <uv-number-box v-model="form.num" :min="1"></uv-number-box>
  45. </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. import { mapState } from 'vuex'
  51. export default {
  52. data() {
  53. return {
  54. form: {
  55. categoryId: 0,
  56. name: '',
  57. num: 1,
  58. length: '',
  59. wide: '',
  60. },
  61. fileList: [],
  62. }
  63. },
  64. computed: {
  65. ...mapState(['category']),
  66. },
  67. mounted() {
  68. this.closeForm()
  69. },
  70. methods: {
  71. submit(fn) {
  72. this.form.pic = this.fileList.map((item) => item.url).join(",")
  73. let form = {
  74. ...this.form
  75. }
  76. if (this.$utils.verificationAll(form, {
  77. pic: '请上传物品照片',
  78. name: '请输入物品名称',
  79. length: '请输入物品长度',
  80. wide: '请输入物品宽度',
  81. })) {
  82. return
  83. }
  84. fn && fn(form)
  85. },
  86. closeForm() {
  87. this.form = {
  88. categoryId: 0,
  89. name: '',
  90. num: 1,
  91. length: '',
  92. wide: '',
  93. }
  94. this.fileList = []
  95. if (this.category.length) {
  96. this.form.categoryId = this.category[0].id
  97. }
  98. },
  99. deleteImage(e) {
  100. this.fileList.splice(e.index, 1)
  101. },
  102. afterRead(e) {
  103. let self = this
  104. e.file.forEach(file => {
  105. self.$Oss.ossUpload(file.url).then(url => {
  106. self.fileList.push({
  107. url
  108. })
  109. })
  110. })
  111. },
  112. }
  113. }
  114. </script>
  115. <style scoped lang="scss">
  116. .form {
  117. padding: 20rpx 0;
  118. .shopName {
  119. display: flex;
  120. align-items: center;
  121. background-color: #FFF;
  122. margin: 10rpx 0 0 0;
  123. padding: 10rpx 20rpx;
  124. >view:nth-of-type(1) {
  125. width: 30%;
  126. // font-weight: 700;
  127. }
  128. >view:nth-of-type(2) {
  129. width: 70%;
  130. // padding: 0 20rpx 0 0;
  131. border-radius: 10rpx;
  132. overflow: hidden;
  133. input {
  134. background-color: #f5f5f5;
  135. // color: #a4a4a4;
  136. font-size: 28rpx;
  137. padding: 8rpx 8rpx 8rpx 15rpx;
  138. }
  139. }
  140. }
  141. }
  142. .list {
  143. display: flex;
  144. flex-wrap: wrap;
  145. font-size: 22rpx;
  146. .act {
  147. color: $uni-color;
  148. border: 1px solid $uni-color;
  149. background-color: #F9E7DE;
  150. }
  151. view {
  152. border-radius: 15rpx;
  153. background-color: #F3F3F3;
  154. border: 1px solid #F3F3F3;
  155. margin: 10rpx;
  156. display: flex;
  157. justify-content: center;
  158. padding: 10rpx 20rpx;
  159. }
  160. }
  161. </style>