editGoodsCat.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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="obj.name" name="name" 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 required">
  20. <text>排序</text>
  21. </view>
  22. <view class="desc">
  23. <input type="text" :value="obj.num" name="num" class="input-box" placeholder="请输入"
  24. placeholder-class="desc-placeholder">
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <!-- -->
  30. <view class="info-car">
  31. <view class="title-block">
  32. <view class="title">分类图标</view>
  33. </view>
  34. <view class="content" @click="ChooseImage">
  35. <image v-if="thumb" class="logo-img" :src="URL+''+thumb">
  36. </image>
  37. <image v-else src="../static/images/icon_6.png" class="logo-img"></image>
  38. </view>
  39. </view>
  40. <!-- -->
  41. <view class="footer-bar">
  42. <view class="content flex flex-center" style="background: none;position: relative;">
  43. <button class="btn" hover-class="none" form-type="submit">
  44. 立即提交
  45. </button>
  46. </view>
  47. </view>
  48. </form>
  49. </view>
  50. </template>
  51. <script>
  52. export default {
  53. data() {
  54. return {
  55. URL: getApp().globalData.URL,
  56. addr: "",
  57. payType: 1,
  58. vipType: 1,
  59. obj: {},
  60. imgid: "",
  61. thumb: "",
  62. info:{}
  63. }
  64. },
  65. onLoad(e) {
  66. if(e.id){
  67. this.obj=uni.getStorageSync("category_info");
  68. this.thumb =this.obj.thumb;
  69. }
  70. },
  71. methods: {
  72. // storeinfo(id) {
  73. // this.request({
  74. // url: 'Smdcshop/cygoods_category_info',
  75. // data: {
  76. // id: id
  77. // }
  78. // }).then(res => {
  79. // console.log(res)
  80. // if (res.code == 200) {
  81. // this.obj = res.data;
  82. // this.thumb = res.data.thumb;
  83. // }
  84. // })
  85. // },
  86. onRegionChange(e) {
  87. console.log(e)
  88. this.addr = e.detail.value.join(' ')
  89. },
  90. onPayTypeChange(e) {
  91. this.payType = e.detail.value
  92. },
  93. onVipTypeChange(e) {
  94. this.vipType = e.detail.value
  95. },
  96. ChooseImage(e) {
  97. uni.chooseImage({
  98. count: 1, //默认9
  99. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  100. sourceType: ['album'], //从相册选择
  101. success: (res) => {
  102. console.log(res)
  103. // var tempFilesSize = res.tempFiles[0].size;//获取图片的大小,单位B
  104. res.tempFilePaths.forEach((v, i) => {
  105. // console.log(v)
  106. this.Upload({
  107. url: "Smdcshop/upload",
  108. data: {
  109. url: v,
  110. type: "",
  111. token: "",
  112. admin_id: uni.getStorageSync("admin_id")
  113. }
  114. }).then(res => {
  115. console.log(res, "res")
  116. this.imgid = res.id;
  117. this.thumb = res.src;
  118. }).catch(err => {
  119. uni.showToast({
  120. title: err.message,
  121. icon: 'none'
  122. })
  123. });
  124. })
  125. },
  126. });
  127. },
  128. onSubmit(e) {
  129. let url;
  130. var data = e.detail.value;
  131. data.admin_id = uni.getStorageSync("admin_id")
  132. data.thumb = this.imgid
  133. console.log(data, "data")
  134. if (this.obj.id) {
  135. data.id = this.obj.id
  136. url = "Smdcshop/jftype_update"
  137. } else {
  138. url = 'Smdcshop/jftype_add'
  139. }
  140. if (!data.name) {
  141. uni.showToast({
  142. title: "必填项不能为空",
  143. icon: 'none'
  144. })
  145. return false
  146. }
  147. this.request({
  148. url,
  149. data: data
  150. }).then(res => {
  151. if (res.code == 200) {
  152. uni.showToast({
  153. title: res.message,
  154. icon: 'none'
  155. })
  156. setTimeout(() => {
  157. if(this.obj.id){
  158. uni.navigateBack({
  159. delta:2
  160. })
  161. }else{
  162. uni.navigateBack()
  163. }
  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>