index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <template>
  2. <view :style="{ minHeight: sys.windowHeight + 'px' }"
  3. :class="[$tm.vx.state().tmVuetify.black ? 'black' : ' ']">
  4. <tm-menubars title="搭配详情" :shadow="0" :showback="true"></tm-menubars>
  5. <div class="zhuti">
  6. <tm-sheet class="kuang" style="padding-bottom: 10px !important;">
  7. <view style="width: 94%;margin:0 auto;">
  8. <image class="chuanda" src="/static/img/108.png" mode="widthFix"></image>
  9. <view class="shuru">
  10. <tm-form>
  11. <view class="text-size-m text-white">请输入搭配名称</view>
  12. <tm-input v-model="familyname" name="title" clear placeholder="出席重要场合" clear></tm-input>
  13. </tm-form>
  14. </view>
  15. <view>
  16. <view class="biaoti text-white mt-30 text-size-m"><view class="mr-10"></view>分类</view>
  17. <tm-tabs @change="fenlei" class="C1b1b1b qiehuan" color="white" align="left" v-model="activeIndex" :list="listfl" range-key="title"></tm-tabs>
  18. <view class="biaoti text-white mt-30 text-size-m"><view class="mr-10"></view>场景</view>
  19. <tm-tabs class="C1b1b1b qiehuan" color="white" align="left" v-model="activeIndex1" :list="list1" range-key="title"></tm-tabs>
  20. </view>
  21. <!-- <view v-if="off==1" class="text-align-center mt-20 text-white">丝缎质感纹理风衣</view> -->
  22. <!-- <view v-if="off==1" class="text-align-center mt-10 text-size-s">丝滑如肌肤</view> -->
  23. </view>
  24. </tm-sheet>
  25. </div>
  26. <!-- <view class="goumai shangpin" v-if="off==1" >
  27. <view class="pt-20"><text class="ml-20">衣物名</text><text class="fr mr-20 text-gray text-size-s">丝缎质感纹理风衣</text></view>
  28. <view class="pa-20"><tm-cartCellListFood v-on:jiaruFun="jiarufuFun" v-for="item in test1" :typeclick="typeclick1" :mdata="item" :cart-num.sync="item.buy"></tm-cartCellListFood></view>
  29. </view> -->
  30. <tm-sheet :shadow="24" class="jiaoxi xiao">
  31. <tm-tabs align="center" class="qiehuan1" v-model="activeIndex5" :list="list5" range-key="title"></tm-tabs>
  32. </tm-sheet>
  33. <!-- 单品 -->
  34. <view class="zhuti shangpin">
  35. <tm-sheet :padding="[0, 0]" class="jiaoxi xiao">
  36. <tm-cartCellListFood v-on:genghuan="genghuan" v-for="item in test" :typeclick="typeclick" :mdata="item" :cart-num.sync="item.buy"></tm-cartCellListFood>
  37. </tm-sheet>
  38. </view>
  39. <!-- <tm-button :round="24" class="sao mb-40 mt-40" block>保存</tm-button> -->
  40. <view class="anniu" v-if="off==2">
  41. <tm-button @click="shanchu()" :round="24" theme="gray" size="n">删除</tm-button>
  42. <tm-button @click="baocun()" :round="24" class="fr" theme="primary" size="n">保存</tm-button>
  43. </view>
  44. <view class="anniu" v-if="off==1">
  45. <tm-button class="anniubaocun " @click="baocun()" :round="24" theme="primary" size="n">保存</tm-button>
  46. </view>
  47. <view style="clear: both;"></view>
  48. <!-- 弹出层消息 -->
  49. <tm-message ref="toast"></tm-message>
  50. </view>
  51. </template>
  52. <script>
  53. import{myRequest} from '@/api/request.js'
  54. export default {
  55. data() {
  56. return {
  57. listfl:[],
  58. listflall:[],
  59. familyname:'',
  60. off:1,
  61. activeIndex:0,
  62. activeIndex5:0,
  63. list1:[],
  64. list1all:[],
  65. activeIndex1:0,
  66. list5:[ '搭配内的购物清单'],
  67. test: [],
  68. test1: [{
  69. img: '../../static/img/83.png',
  70. title: '丝缎质感纹理风衣',
  71. label: '黑色 - 6518/320',
  72. id: 3,
  73. buy: 0,
  74. itemId: 0
  75. }],
  76. typeclick1:6,//1加入购物车,2购物车,3前往购买,4,5
  77. typeclick:7,//1加入购物车,2购物车,3前往购买,4,5
  78. ids:[]
  79. };
  80. },
  81. onLoad(e) {
  82. this.off=e.type?e.type:1;//1保存2是修改
  83. this.id=e.id?e.id:13;
  84. if(this.off==1){
  85. this.huancun();
  86. }else{
  87. this.getDate();
  88. }
  89. },
  90. created() {
  91. this.sys = uni.getSystemInfoSync();
  92. this.getFl();
  93. this.getCj();
  94. this.fenleichange();
  95. },
  96. methods: {
  97. getCj(){
  98. var that=this;
  99. myRequest({
  100. url: "/api/Scene/sceneList",
  101. method:'post',
  102. data:{}
  103. }).then(res => {
  104. if (res.data.code == 200) {
  105. if(res.data.data.length != 0){
  106. // that.listfl=['全部'];
  107. that.list1=[];
  108. for(let i=0;i<res.data.data.length;i++){
  109. that.list1.push(res.data.data[i].scene_name)
  110. }
  111. that.list1all=res.data.data;
  112. }
  113. }else{
  114. that.list1=[];
  115. }
  116. })
  117. },
  118. huancun(){
  119. var ids=[];
  120. console.log(11111111111)
  121. console.log(uni.getStorageSync("datalist"))
  122. if(uni.getStorageSync("datalist")){
  123. var datalist=uni.getStorageSync("datalist");
  124. this.test=[];
  125. for(let i=0;i<datalist.length;i++){
  126. this.test.push({
  127. img: datalist[i].image,
  128. title: datalist[i].goods_name,
  129. label: datalist[i].description,
  130. price: '',
  131. id: datalist[i].id,
  132. buy: 0,
  133. itemId: 0
  134. })
  135. ids.push(datalist[i].id)
  136. }
  137. this.ids=ids;
  138. }
  139. },
  140. genghuan(data){
  141. var that=this;
  142. uni.navigateTo({
  143. url: "/pages/genghuan/index?type=tihuan&id="+data.data.id,
  144. })
  145. },
  146. getDate(){
  147. var that=this;
  148. myRequest({
  149. url: "/api/Collocation/matchingSchemeDetails",
  150. method:'post',
  151. data:{type:2,id:that.id}
  152. }).then(res => {
  153. if (res.data.code == 200) {
  154. that.familyname=res.data.data.data.title;
  155. var datalist=res.data.data.details,datalist1=[];
  156. for(let i=0;i<datalist.length;i++){
  157. datalist1.push(datalist[i].goods)
  158. }
  159. uni.setStorageSync("datalist",datalist1)
  160. that.huancun();
  161. }else{
  162. }
  163. })
  164. },
  165. shanchu(){
  166. var that=this;
  167. myRequest({
  168. url: "/api/Collocation/customizedDeleteCollocation",
  169. method:'post',
  170. data:{id:that.id}
  171. }).then(res => {
  172. console.log(res.data)
  173. if (res.data.code == 200) {
  174. let pages = getCurrentPages(); // 当前页面
  175. let beforePage = pages[pages.length - 2]; // 前一个页面
  176. uni.navigateBack({
  177. delta: 1,
  178. success: function() {
  179. beforePage.$vm.initshow()
  180. }
  181. });
  182. that.$refs.toast.show({model:'success',label:res.data.msg})
  183. }else{
  184. that.$refs.toast.show({model:'error',label:res.data.msg})
  185. }
  186. })
  187. },
  188. fenleichange(){
  189. var that=this;
  190. myRequest({
  191. url: "/api/MemberInfo/getFamilyMember",
  192. method:'post',
  193. data:{family_id:uni.getStorageSync("family_id")}
  194. }).then(res => {
  195. if (res.data.code == 200) {
  196. if(res.data.data.length != 0){
  197. var wu=0;
  198. for(let i=0;i<res.data.data.length;i++){
  199. if(res.data.data[i].checked==1){
  200. wu=1;
  201. that.itemuser=res.data.data[i];
  202. }
  203. }
  204. if(wu==0){
  205. that.itemuser=res.data.data[0];
  206. }
  207. }else{
  208. that.itemuser=0;
  209. }
  210. }else{
  211. that.itemuser=0;
  212. }
  213. })
  214. },
  215. fenlei(e){
  216. this.activeIndex=e;
  217. },
  218. getFl(){
  219. var that=this;
  220. myRequest({
  221. url: "/api/Category/getCollocationClassList",
  222. method:'post',
  223. data:{}
  224. }).then(res => {
  225. if (res.data.code == 200) {
  226. if(res.data.data.length != 0){
  227. // that.listfl=['全部'];
  228. that.listfl=[];
  229. for(let i=0;i<res.data.data.length;i++){
  230. that.listfl.push(res.data.data[i].category_name)
  231. }
  232. that.listflall=res.data.data;
  233. }
  234. }else{
  235. that.listfl=[];
  236. }
  237. })
  238. },
  239. baocun(){
  240. var that=this;
  241. if(that.familyname==""){
  242. that.$refs.toast.show({model:'error',label:'请输入搭配名称'})
  243. return
  244. }
  245. var obj={
  246. title:that.familyname,
  247. category_id:that.listflall[that.activeIndex].id,
  248. memberinfo_id:that.itemuser.id,
  249. ids:this.ids,
  250. scene_id:that.list1all[that.activeIndex5].id
  251. }
  252. if(this.off==1){
  253. // 保存
  254. var url="/api/Collocation/customizedCollocation"
  255. }else{
  256. obj['id']=that.id;
  257. var url="/api/Collocation/customizedUpdateCollocation"
  258. }
  259. myRequest({
  260. url: url,
  261. method:'post',
  262. data:obj
  263. }).then(res => {
  264. console.log(res.data)
  265. if (res.data.code == 200) {
  266. setTimeout(function(){
  267. let pages = getCurrentPages(); // 当前页面
  268. let beforePage = pages[pages.length - 2]; // 前一个页面
  269. uni.navigateBack({
  270. delta: 1,
  271. success: function() {
  272. beforePage.$vm.initshow()
  273. }
  274. });
  275. },2000)
  276. that.$refs.toast.show({model:'success',label:res.data.msg})
  277. }else{
  278. that.$refs.toast.show({model:'error',label:res.data.msg})
  279. }
  280. })
  281. console.log(obj)
  282. },
  283. jiarufuFun(data){
  284. // uni.navigateTo({
  285. // url: "/pages/shopdetail/index",
  286. // })
  287. console.log(data)
  288. },
  289. },
  290. }
  291. </script>
  292. <style lang="scss">
  293. /deep/ .tm-menubars .body{
  294. background-color: #1b1b1b !important;
  295. }
  296. /deep/ .zhuti{padding: 10px 10px;}
  297. /deep/ .kuang{margin:0 !important;padding: 0px !important;}
  298. .chuanda{width: 100%;margin-top:10px;}
  299. .shuru{background: #0D0D0D;padding: 10px;margin-top: 20px;}
  300. /deep/ .shuru .grey-darken-5{
  301. background-color: #0d0d0d!important;
  302. padding: 0px !important;
  303. }
  304. .shuru{border:1px solid #303030;border-radius: 10px;}
  305. /deep/ .shuru .text-primary.bk{color:#303030 !important;}
  306. /deep/ .shuru .border-grey-darken-4-b-1{border-bottom:none !important;}
  307. /deep/ .qiehuan .tm-tabs-con-item-border{display: none;}
  308. /deep/ .qiehuan .tm-tabs-con-item-text{background: #303440;height: 26px;line-height: 26px;
  309. padding-left: 14px;padding-right: 14px;margin-top: 17%;border-radius: 20px;margin-left: 10px;}
  310. /deep/ .qiehuan .text-white{
  311. font-size: 14px;
  312. background: #0178FD;
  313. height: 26px;
  314. vertical-align: middle;
  315. line-height: 26px;
  316. border-radius: 20px;
  317. padding-left: 14px;
  318. padding-right: 14px;
  319. margin-top: 17%;
  320. }
  321. .biaoti view{width:5px;height:19px;background: #0178FD;float: left;border-radius: 10px;}
  322. /deep/ .qiehuan1 .text-primary{color: white !important;}
  323. /deep/ .jiaoxi{margin:0 !important;padding: 8px !important;}
  324. /deep/ .shangpin .white.bk{background-color:#1b1b1b!important;}
  325. /deep/ .shangpin .tm-cartCellListFood{padding: 0px 0px 5px 0px !important;
  326. margin-top: 5px !important;border-bottom: 1px solid #1B1B1B;}
  327. /deep/ .shangpin .border-t-1.bk{border-top:1px solid #1b1b1b!important;}
  328. /deep/ .shangpin .round-3{width:120px !important;height:110px !important;}
  329. /deep/ .shangpin .tm-cartCellListFood-img{width:120px !important;height:110px !important;}
  330. /deep/ .shangpin .title{color: white !important;}
  331. /deep/ .shangpin .text-red{color: white !important;}
  332. .sao{width: 88%;display: block;margin: 0 auto;padding-bottom: 60px;margin-top: 20px;}
  333. .goumai{background: #1B1B1B;margin-bottom: 10px;}
  334. .anniu{width: 70%;margin: 0 auto;margin-top: 20px;padding-bottom: 30px;}
  335. /deep/ .anniubaocun{width: 100%;}
  336. /deep/ .anniubaocun .flex-center{width: 100% !important;}
  337. </style>