inputGoodsDetils.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <view class="input_content">
  3. <view class="input_content_textarea">
  4. <textarea v-model="prodectContent.store_name" :placeholder="title" placeholder-class="placeholderStyle" :maxlength="maxLength"/>
  5. <view><text v-if="prodectContent.store_name">{{prodectContent.store_name.length}}</text><text v-else>0</text>/{{maxLength}}</view>
  6. </view>
  7. <view class="input_content_photo">
  8. <view class="input_content_photo_adPh" v-for="(item, index) in prodectContent.imageList" :key="index">
  9. <image :src="item" class="myimg2 photos"></image>
  10. <view class="input_content_photo_adPh_jiao" @click="deleteImage(index)"><image src="../static/images/close.png" mode=""></image></view>
  11. </view>
  12. <view v-if="isUpload" class="input_content_photo_adPh" @click="clk">
  13. <view><image src="../static/images/creamer.png" mode="widthFix"></image></view>
  14. <view>添加图片</view>
  15. </view>
  16. </view>
  17. <view class="input_content_describe" v-if="isShowDescribe">
  18. <view class="input_content_describe_title">
  19. <view class="input_content_describe_title_msg">商品简介</view>
  20. <view class="input_content_describe_title_num">
  21. <text v-if="prodectContent.store_info">{{prodectContent.store_info.length}}</text>
  22. <text v-else>0</text>/200
  23. </view>
  24. </view>
  25. <view class="input_content_describe_textarea"><textarea v-model="prodectContent.store_info" value="" placeholder="请填写商品简介" placeholderClass="placeholderClass" maxlength="200"/></view>
  26. </view>
  27. <view class="input_content_keyword" v-if="isShowDescribe">
  28. <view class="input_content_keyword_label">关键字</view>
  29. <view class="input_content_keyword_value"><input v-model="prodectContent.keyword" type="text" value="" placeholder="填写关键字" /></view>
  30. </view>
  31. <avatar @upload="doUpload" @getName="getImgName" quality="1" ref="avatar" selWidth="250upx" selHeight="250upx"></avatar>
  32. </view>
  33. </template>
  34. <script>
  35. import { chooseImage } from '../../../libs/uniApi.js';
  36. import { TOKENNAME, HTTP_REQUEST_URL } from '../../../config/app.js';
  37. import avatar from "@/components/yq-avatar/yq-avatar.vue";
  38. import store from '@/store';
  39. export default {
  40. components: {
  41. avatar
  42. },
  43. props: {
  44. isShowDescribe: {
  45. type: Boolean,
  46. default: false
  47. },
  48. isMultiple: {
  49. type: Boolean,
  50. default: true
  51. },
  52. maxLength: {
  53. type: Number,
  54. default: 12
  55. },
  56. title: {
  57. type: String,
  58. default: ''
  59. },
  60. prodectContent: {
  61. type: Object,
  62. default: ()=>{return {imageList: []}}
  63. }
  64. },
  65. data() {
  66. return {
  67. uploadImg: this.prodectContent.imageList,
  68. isUpload: true,
  69. imgName: ""
  70. };
  71. },
  72. watch: {
  73. prodectContent: {
  74. handler(val) {
  75. this.$emit('getProductContent', val);
  76. },
  77. deep: true
  78. },
  79. uploadImg: {
  80. handler(val) {
  81. if(this.isMultiple){
  82. this.isUpload = val.length<6?true : false
  83. }else{
  84. this.isUpload = val.length <1?true : false
  85. }
  86. },
  87. deep: true
  88. }
  89. },
  90. mounted() {
  91. },
  92. methods: {
  93. handleChooseImage() {
  94. let that = this;
  95. that.$util.uploadImageOne('upload/image', function (res) {
  96. that.uploadImg.push(res.data.path);
  97. that.$set(that.prodectContent,'imageList',that.uploadImg);
  98. });
  99. },
  100. clk() {
  101. let avatar = this.$refs.avatar;
  102. avatar.fChooseImg(1,{selWidth: '350upx', selHeight: '350upx', inner: true});
  103. },
  104. doUpload(rsp) {
  105. console.log(rsp);
  106. let that = this
  107. uni.uploadFile({
  108. url: HTTP_REQUEST_URL + '/api/upload/image/field',
  109. filePath: rsp.path,
  110. name: 'field',
  111. formData: {
  112. 'filename': rsp.path,
  113. 'name': that.imgName
  114. },
  115. header: {
  116. // #ifdef MP
  117. "Content-Type": "multipart/form-data",
  118. // #endif
  119. [TOKENNAME]: 'Bearer ' + store.state.app.token
  120. },
  121. success: (uploadFileRes) => {
  122. console.log(uploadFileRes.data);
  123. let imgData = JSON.parse(uploadFileRes.data)
  124. that.prodectContent.imageList.push(imgData.data.path)
  125. },
  126. complete(res) {
  127. console.log(res)
  128. }
  129. });
  130. },
  131. getImgName(name){
  132. this.imgName = name
  133. },
  134. // 删除图片
  135. deleteImage(index) {
  136. this.prodectContent.imageList.splice(index, 1);
  137. this.uploadImg = this.prodectContent.imageList
  138. }
  139. }
  140. };
  141. </script>
  142. <style lang="scss" scoped>
  143. .input_content {
  144. background: #fff;
  145. padding: 20rpx 40rpx 40rpx 30rpx;
  146. width: 710rpx;
  147. margin: auto;
  148. box-sizing: border-box;
  149. border-radius: 10rpx;
  150. &_textarea {
  151. border-bottom: 1px solid #eeeeee;
  152. padding-bottom: 19rpx;
  153. textarea {
  154. height: 114rpx;
  155. }
  156. > view {
  157. text-align: right;
  158. color: #666666;
  159. font-size: 24rpx;
  160. }
  161. }
  162. &_photo {
  163. margin-top: 41rpx;
  164. display: flex;
  165. flex-wrap: wrap;
  166. .photos{
  167. width: 156rpx;
  168. height: 156rpx;
  169. }
  170. &_adPh {
  171. position: relative;
  172. width: 156rpx;
  173. height: 156rpx;
  174. border: 1px solid #dddddd;
  175. display: flex;
  176. flex-direction: column;
  177. justify-content: center;
  178. border-radius: 8rpx;
  179. margin-right: 30rpx;
  180. margin-bottom: 30rpx;
  181. > image {
  182. height: 100%;
  183. margin: auto;
  184. }
  185. > view:nth-child(1) {
  186. height: 37rpx;
  187. margin-bottom: 16rpx;
  188. display: flex;
  189. justify-content: center;
  190. image {
  191. width: 45rpx;
  192. display: block;
  193. }
  194. }
  195. > view:nth-child(2) {
  196. text-align: center;
  197. color: #bbbbbb;
  198. font-size: 24rpx;
  199. }
  200. &_jiao {
  201. position: absolute;
  202. top: -14rpx;
  203. right: -14rpx;
  204. width: 40rpx;
  205. height: 40rpx;
  206. background: #e93323;
  207. display: flex;
  208. align-items: center;
  209. justify-content: center;
  210. border-radius: 50%;
  211. image {
  212. width: 16rpx;
  213. height: 16rpx;
  214. }
  215. }
  216. }
  217. }
  218. &_describe {
  219. border-top: 1px solid #eeeeee;
  220. padding-top: 30rpx;
  221. padding-bottom: 47rpx;
  222. border-bottom: 1px solid #eeeeee;
  223. &_title {
  224. display: flex;
  225. align-items: center;
  226. justify-content: space-between;
  227. &_msg {
  228. color: #333333;
  229. font-size: 30rpx;
  230. }
  231. &_num {
  232. color: #666666;
  233. font-size: 24rpx;
  234. }
  235. }
  236. &_textarea {
  237. border-radius: 10px;
  238. margin-top: 20rpx;
  239. height: 180rpx;
  240. background: #f5f5f5;
  241. padding: 20rpx;
  242. textarea {
  243. font-size: 28rpx;
  244. }
  245. }
  246. }
  247. &_keyword {
  248. padding-top: 32rpx;
  249. display: flex;
  250. align-items: center;
  251. justify-content: space-between;
  252. font-size: 30rpx;
  253. &_value {
  254. flex: 1;
  255. margin-left: 30rpx;
  256. input {
  257. width: 100%;
  258. text-align: right;
  259. }
  260. }
  261. }
  262. }
  263. .placeholderClass {
  264. color: #bbbbbb;
  265. font-size: 28rpx;
  266. }
  267. </style>