spec.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <view class="content">
  3. <view class="top" v-if="specList.length == 0">
  4. <view class="add hflex acenter jcenter" @click="open(-1)">添加规格分类</view>
  5. </view>
  6. <view class="top1" v-else>
  7. <block v-for="(item,index) in specList" :key="index">
  8. <view class="box">
  9. <view class="hflex acenter jbetween box-top">
  10. <view class="hflex acenter">
  11. <view class="name text_hide">{{item.name}}</view>
  12. <image src="/static/images/common/edit_icon.png" style="width: 28rpx;height: 28rpx;" @click="open(index)"></image>
  13. </view>
  14. <view class="hflex acenter" @click="delSpec(index)">
  15. <image src="/static/images/common/delete.png" style="width: 28rpx;height: 28rpx;"></image>
  16. <view class="right">删除</view>
  17. </view>
  18. </view>
  19. <view class="hflex acenter fwrap" style="padding: 32rpx 0;">
  20. <block v-for="(item2,index2) in item.list" :key="index2">
  21. <view class="options hflex acenter">
  22. <view class="text text-right">{{item2.name}}</view>
  23. <image src="/static/images/common/close_icon.png" style="margin-left: 16rpx;width: 28rpx;height: 28rpx;" @click="delOptions(index,index2)"></image>
  24. </view>
  25. </block>
  26. <view class="options hflex acenter">
  27. <view class="text text_blue" @click="add(index,item.name)">+添加规格选项</view>
  28. </view>
  29. </view>
  30. </view>
  31. </block>
  32. <view class="add hflex acenter jcenter" @click="open(-1)">添加规格分类</view>
  33. </view>
  34. <view class="bottom">
  35. <view class="btn hflex acenter jcenter" @click="next">
  36. 下一步
  37. </view>
  38. </view>
  39. <u-popup :show="show" round="10" mode="center" @close="close" :safeAreaInsetBottom="false">
  40. <view class="popu">
  41. <view class="popu_title">添加规格分类</view>
  42. <u-input v-model="name" border="none" maxlength="15" shape="circle" placeholder="请输入"></u-input>
  43. <view class="hflex acenter jcenter btn_group">
  44. <view class="left_btn" @click="close">取消</view>
  45. <view class="right_btn" @click="save">保存</view>
  46. </view>
  47. </view>
  48. </u-popup>
  49. </view>
  50. </template>
  51. <script>
  52. import $api from '@/static/js/api.js'
  53. var that = ''
  54. export default {
  55. data() {
  56. return {
  57. specList: [],
  58. options: [],
  59. show: false,
  60. name: '',
  61. edit: false,
  62. editIndex: 0,
  63. good_id: '',
  64. }
  65. },
  66. onLoad(options) {
  67. that = this
  68. if(options.good_id) {
  69. that.good_id = options.good_id
  70. }
  71. if(options.items) {
  72. that.getData(options.items)
  73. }
  74. },
  75. methods: {
  76. getData(data) {
  77. var data = JSON.parse(data)
  78. console.log(data);
  79. that.specList = data
  80. },
  81. open(index) {
  82. if(index == -1) {
  83. that.edit = false
  84. } else {
  85. that.edit = true
  86. that.editIndex = index
  87. }
  88. that.show = true
  89. },
  90. close() {
  91. that.show = false
  92. },
  93. save() {
  94. if(that.name == '') {
  95. $api.info('请输入规格分类')
  96. return
  97. }
  98. var data = {
  99. name: that.name
  100. }
  101. if(that.edit) {
  102. that.$set(that.specList[that.editIndex],'name',that.name)
  103. } else {
  104. that.specList.push(data)
  105. }
  106. that.name = ''
  107. that.close()
  108. },
  109. delSpec(index) {
  110. that.specList.splice(index,1)
  111. },
  112. delOptions(index,index2) {
  113. console.log(that.specList);
  114. that.specList[index].list.splice(index2,1)
  115. },
  116. add(index,name) {
  117. var url = ''
  118. if(that.specList[index].list) {
  119. url = '/pages/good/options?index='+index+'&data='+JSON.stringify(that.specList[index].list) + '&group=' + name
  120. } else {
  121. url = '/pages/good/options?index='+index + '&group=' + name
  122. }
  123. $api.jump(url)
  124. },
  125. next() {
  126. $api.jump('/pages/good/setting?data=' + JSON.stringify(that.specList) + '&good_id=' + that.good_id,1)
  127. }
  128. },
  129. }
  130. </script>
  131. <style lang="scss" scoped>
  132. .content::v-deep {
  133. .top {
  134. width: 100%;
  135. min-height: calc(100vh - 166rpx);
  136. }
  137. .top1 {
  138. width: 100%;
  139. min-height: calc(100vh - 166rpx);
  140. background: #F5F5F5;
  141. .box {
  142. width: 100%;
  143. margin-top: 20rpx;
  144. box-sizing: border-box;
  145. padding: 0 30rpx;
  146. background: #FFFFFF;
  147. .box-top {
  148. width: 100%;
  149. padding: 24rpx 0;
  150. border-bottom: 1rpx solid #F5F5F5;
  151. .name {
  152. width: 500rpx;
  153. font-size: 30rpx;
  154. font-weight: 500;
  155. color: #222222;
  156. line-height: 42rpx;
  157. padding-right: 12rpx;
  158. }
  159. .right {
  160. font-size: 24rpx;
  161. font-weight: 400;
  162. color: #8F8F8F;
  163. line-height: 34rpx;
  164. padding-left: 12rpx;
  165. }
  166. }
  167. .options {
  168. background: #F5F5F5;
  169. border-radius: 28px;
  170. padding: 10rpx 32rpx;
  171. margin: 0 20rpx 32rpx 0;
  172. .text {
  173. font-size: 26rpx;
  174. font-weight: 400;
  175. color: #333333;
  176. line-height: 36rpx;
  177. }
  178. .text-right {
  179. padding-right: 16rpx;
  180. border-right: 1rpx solid #D8D8D8;
  181. }
  182. .text_blue {
  183. color: #5471FF;
  184. }
  185. }
  186. }
  187. }
  188. .add {
  189. margin: 102rpx auto 186rpx;
  190. width: 390rpx;
  191. height: 84rpx;
  192. border-radius: 42rpx;
  193. border: 2rpx solid #5471FF;
  194. font-size: 30rpx;
  195. font-weight: 400;
  196. color: #5471FF;
  197. line-height: 42rpx;
  198. }
  199. .bottom {
  200. width: 100%;
  201. height: 166rpx;
  202. background: #FFFFFF;
  203. box-sizing: border-box;
  204. padding: 8rpx 30rpx 0;
  205. position: fixed;
  206. bottom: 0;
  207. z-index: 99;
  208. .btn {
  209. width: 100%;
  210. height: 84rpx;
  211. background: #5471FF;
  212. border-radius: 46rpx;
  213. font-size: 36rpx;
  214. font-weight: 500;
  215. color: #FFFFFF;
  216. line-height: 50rpx;
  217. }
  218. }
  219. .popu {
  220. width: 590rpx;
  221. background: #FFFFFF;
  222. border-radius: 28rpx;
  223. box-sizing: border-box;
  224. padding: 0 10rpx;
  225. .popu_title {
  226. width: 100%;
  227. font-size: 32rpx;
  228. font-weight: 400;
  229. color: #222222;
  230. line-height: 44rpx;
  231. text-align: center;
  232. padding: 48rpx 0;
  233. }
  234. .u-input {
  235. width: 490rpx;
  236. height: 80rpx;
  237. background: #F5F5F5;
  238. border-radius: 40rpx;
  239. margin: 0 auto;
  240. padding: 0 32rpx !important;
  241. }
  242. .btn_group {
  243. width: 100%;
  244. margin-top: 56rpx;
  245. border-top: 1rpx solid #F5F5F5;
  246. padding: 0 0;
  247. .left_btn {
  248. width: 50%;
  249. padding: 28rpx 108rpx;
  250. border-right: 1rpx solid #F5F5F5;
  251. font-size: 32rpx;
  252. font-weight: 400;
  253. color: #222222;
  254. line-height: 44rpx;
  255. }
  256. .right_btn {
  257. width: 50%;
  258. padding: 0 108rpx;
  259. font-size: 32rpx;
  260. font-weight: 400;
  261. color: #5471FF;
  262. line-height: 44rpx;
  263. }
  264. }
  265. }
  266. }
  267. </style>