editGoodsCat.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <view class="container">
  3. <form @submit="onSubmit">
  4. <view class="page-block">
  5. <view class="page-title-block">
  6. <view class="title">分类信息</view>
  7. </view>
  8. <view class="content">
  9. <view class="cell flex flex-y-center">
  10. <view class="title-block required">
  11. <text>分类名称</text>
  12. </view>
  13. <view class="desc">
  14. <input type="text" :value="info.title" name="title" class="input-box" placeholder="请输入"
  15. placeholder-class="desc-placeholder">
  16. </view>
  17. </view>
  18. <view class="cell flex flex-y-center">
  19. <view class="title-block ">
  20. <text>分类描述</text>
  21. </view>
  22. <view class="desc">
  23. <input type="text" :value="info.keywords" name="keywords" class="input-box"
  24. placeholder="请输入" placeholder-class="desc-placeholder">
  25. </view>
  26. </view>
  27. <view class="cell flex flex-y-center">
  28. <view class="title-block ">
  29. <text>排序</text>
  30. </view>
  31. <view class="desc">
  32. <input type="text" :value="info.sort" name="sort" class="input-box" placeholder="请输入"
  33. placeholder-class="desc-placeholder">
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. <!-- -->
  39. <view class="info-car">
  40. <view class="title-block">
  41. <view class="title">分类图标</view>
  42. </view>
  43. <view class="content" @click="ChooseImage">
  44. <image v-if="thumb" class="logo-img" :src="URL+''+thumb">
  45. </image>
  46. <image v-else src="../static/images/icon_6.png" class="logo-img"></image>
  47. </view>
  48. </view>
  49. <!-- -->
  50. <view class="footer-bar">
  51. <view class="content flex flex-center" style="background: none;position: relative;">
  52. <button class="btn" hover-class="none" form-type="submit">
  53. 立即提交
  54. </button>
  55. </view>
  56. </view>
  57. </form>
  58. </view>
  59. </template>
  60. <script>
  61. export default {
  62. data() {
  63. return {
  64. URL: getApp().globalData.URL,
  65. addr: "",
  66. payType: 1,
  67. vipType: 1,
  68. info: {},
  69. imgid: "",
  70. thumb: ""
  71. }
  72. },
  73. onLoad(e) {
  74. this.storeinfo(e.id)
  75. },
  76. methods: {
  77. storeinfo(id) {
  78. this.request({
  79. url: 'Smdcshop/cygoods_category_info',
  80. data: {
  81. id: id
  82. }
  83. }).then(res => {
  84. console.log(res)
  85. if (res.code == 200) {
  86. this.info = res.data;
  87. this.thumb = res.data.thumb;
  88. }
  89. })
  90. },
  91. onRegionChange(e) {
  92. console.log(e)
  93. this.addr = e.detail.value.join(' ')
  94. },
  95. onPayTypeChange(e) {
  96. this.payType = e.detail.value
  97. },
  98. onVipTypeChange(e) {
  99. this.vipType = e.detail.value
  100. },
  101. ChooseImage(e) {
  102. // let type = e.currentTarget.dataset.type;
  103. uni.chooseImage({
  104. count: 1, //默认9
  105. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  106. sourceType: ['album'], //从相册选择
  107. success: (res) => {
  108. console.log(res)
  109. // var tempFilesSize = res.tempFiles[0].size;//获取图片的大小,单位B
  110. res.tempFilePaths.forEach((v, i) => {
  111. // console.log(v)
  112. this.Upload({
  113. url: "Smdcshop/upload",
  114. data: {
  115. url: v,
  116. type: "",
  117. token: "",
  118. admin_id: uni.getStorageSync("admin_id")
  119. }
  120. }).then(res => {
  121. console.log(res, "res")
  122. this.imgid = res.id;
  123. this.thumb = res.src;
  124. }).catch(err => {
  125. uni.showToast({
  126. title: err.message,
  127. icon: 'none'
  128. })
  129. });
  130. })
  131. },
  132. });
  133. },
  134. onSubmit(e) {
  135. let url;
  136. var data = e.detail.value;
  137. data.store_id = uni.getStorageSync("store_id")
  138. data.thumb = this.imgid
  139. console.log(data, "data")
  140. if (this.info.id) {
  141. data.id = this.info.id
  142. url = "Smdcshop/cygoods_category_update"
  143. } else {
  144. url = 'Smdcshop/cygoods_category_add'
  145. }
  146. if (!data.title) {
  147. uni.showToast({
  148. title: "必填项不能为空",
  149. icon: 'none'
  150. })
  151. return false
  152. }
  153. this.request({
  154. url,
  155. data: data
  156. }).then(res => {
  157. if (res.code == 200) {
  158. uni.showToast({
  159. title: res.message,
  160. icon: 'none'
  161. })
  162. setTimeout(() => {
  163. uni.navigateBack()
  164. }, 2000)
  165. }
  166. }).catch((res) => {
  167. uni.showToast({
  168. title: res.message,
  169. icon: 'none'
  170. })
  171. });
  172. },
  173. }
  174. }
  175. </script>
  176. <style>
  177. @import url("../static/css/common.css");
  178. page {
  179. background-color: #F4F5F7;
  180. }
  181. .info-car {
  182. margin-top: 25rpx;
  183. background-color: #fff;
  184. padding: 0 25rpx;
  185. }
  186. .info-car .title-block {
  187. border-bottom: 1rpx solid #f5f5f5;
  188. }
  189. .info-car .title {
  190. height: 100rpx;
  191. line-height: 100rpx;
  192. font-size: 30rpx;
  193. color: #333;
  194. font-weight: 600;
  195. }
  196. .info-car .content {
  197. padding: 30rpx 0;
  198. }
  199. .info-car .input-box {
  200. font-size: 28rpx;
  201. color: #333;
  202. }
  203. .info-car .logo-img {
  204. display: block;
  205. width: 120rpx;
  206. height: 120rpx;
  207. }
  208. </style>