index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  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 || off==3">
  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. alldata:{}
  80. };
  81. },
  82. onLoad(e) {
  83. this.off=e.type?e.type:1;//1修改单品返回此页面 2是修改该页面数据 3是新建
  84. this.id=e.id?e.id:13;
  85. if(this.off==1){
  86. this.huancun();
  87. }else if(this.off==2){
  88. this.getDate();
  89. }else if(this.off==3){
  90. this.getCj();
  91. this.getFl();
  92. this.huancun();
  93. }
  94. },
  95. created() {
  96. this.sys = uni.getSystemInfoSync();
  97. this.fenleichange();
  98. },
  99. methods: {
  100. getCj(){
  101. var that=this;
  102. myRequest({
  103. url: "/api/Scene/sceneList",
  104. method:'post',
  105. data:{}
  106. }).then(res => {
  107. if (res.data.code == 200) {
  108. if(res.data.data.length != 0){
  109. // that.listfl=['全部'];
  110. that.list1=[];
  111. for(let i=0;i<res.data.data.length;i++){
  112. that.list1.push(res.data.data[i].scene_name)
  113. if(res.data.data[i].id==that.alldata.scene_id){
  114. that.activeIndex1=i
  115. }
  116. }
  117. that.list1all=res.data.data;
  118. }
  119. }else{
  120. that.list1=[];
  121. }
  122. })
  123. },
  124. huancun(){
  125. var ids=[];
  126. if(uni.getStorageSync("datalist")){
  127. var datalist=uni.getStorageSync("datalist");
  128. this.test=[];
  129. for(let i=0;i<datalist.length;i++){
  130. this.test.push({
  131. img: datalist[i].image,
  132. title: datalist[i].goods_name,
  133. label: datalist[i].description,
  134. price: '',
  135. id: datalist[i].id,
  136. buy: 0,
  137. itemId: 0
  138. })
  139. ids.push(datalist[i].id)
  140. }
  141. this.ids=ids;
  142. }
  143. },
  144. genghuan(data){
  145. var that=this;
  146. uni.navigateTo({
  147. url: "/pages/genghuan/index?type=tihuan&id="+data.data.id,
  148. })
  149. },
  150. getDate(){
  151. var that=this;
  152. myRequest({
  153. url: "/api/Collocation/matchingSchemeDetails",
  154. method:'post',
  155. data:{type:2,id:that.id}
  156. }).then(res => {
  157. if (res.data.code == 200) {
  158. that.familyname=res.data.data.data.title;
  159. that.alldata=res.data.data.data;
  160. var datalist=res.data.data.details,datalist1=[];
  161. that.datalistall=res.data.data.details;
  162. for(let i=0;i<datalist.length;i++){
  163. datalist1.push(datalist[i].goods)
  164. }
  165. uni.setStorageSync("datalist",datalist1)
  166. that.huancun();
  167. that.getFl();
  168. that.getCj();
  169. }else{
  170. }
  171. })
  172. },
  173. shanchu(){
  174. var that=this;
  175. myRequest({
  176. url: "/api/Collocation/customizedDeleteCollocation",
  177. method:'post',
  178. data:{id:that.id}
  179. }).then(res => {
  180. if (res.data.code == 200) {
  181. setTimeout(function(){
  182. let pages = getCurrentPages(); // 当前页面
  183. console.log(pages)
  184. let beforePage = pages[pages.length - 2]; // 前一个页面
  185. uni.navigateBack({
  186. delta: 1,
  187. success: function() {
  188. beforePage.$vm.shuaxin()
  189. }
  190. });
  191. },2000)
  192. that.$refs.toast.show({model:'success',label:res.data.msg})
  193. }else{
  194. that.$refs.toast.show({model:'error',label:res.data.msg})
  195. }
  196. })
  197. },
  198. fenleichange(){
  199. var that=this;
  200. myRequest({
  201. url: "/api/MemberInfo/getFamilyMember",
  202. method:'post',
  203. data:{family_id:uni.getStorageSync("family_id")}
  204. }).then(res => {
  205. if (res.data.code == 200) {
  206. if(res.data.data.length != 0){
  207. var wu=0;
  208. for(let i=0;i<res.data.data.length;i++){
  209. if(res.data.data[i].checked==1){
  210. wu=1;
  211. that.itemuser=res.data.data[i];
  212. }
  213. }
  214. if(wu==0){
  215. that.itemuser=res.data.data[0];
  216. }
  217. }else{
  218. that.itemuser=0;
  219. }
  220. }else{
  221. that.itemuser=0;
  222. }
  223. })
  224. },
  225. fenlei(e){
  226. this.activeIndex=e;
  227. },
  228. getFl(){
  229. var that=this;
  230. myRequest({
  231. url: "/api/Category/getCollocationClassList",
  232. method:'post',
  233. data:{}
  234. }).then(res => {
  235. if (res.data.code == 200) {
  236. if(res.data.data.length != 0){
  237. // that.listfl=['全部'];
  238. that.listfl=[];
  239. for(let i=0;i<res.data.data.length;i++){
  240. that.listfl.push(res.data.data[i].category_name)
  241. if(res.data.data[i].id==that.alldata.category_id){
  242. that.activeIndex=i
  243. }
  244. }
  245. that.listflall=res.data.data;
  246. }
  247. }else{
  248. that.listfl=[];
  249. }
  250. })
  251. },
  252. baocun(){
  253. var that=this,newids=[];
  254. if(that.familyname==""){
  255. that.$refs.toast.show({model:'error',label:'请输入搭配名称'})
  256. return
  257. }
  258. // [{'id':1,'g_id':3},{'id':2,'g_id':4}]
  259. console.log(this.datalistall)
  260. if(this.off==1 || this.off==3){
  261. var obj={
  262. title:that.familyname,
  263. category_id:that.listflall[that.activeIndex].id,
  264. memberinfo_id:that.itemuser.id,
  265. ids:that.ids,
  266. scene_id:that.list1all[that.activeIndex1].id
  267. }
  268. // 保存
  269. var url="/api/Collocation/customizedCollocation"
  270. }else{
  271. for(let i=0;i<that.ids.length;i++){
  272. newids.push({'id':that.datalistall[i].id,'g_id':that.ids[i]})
  273. }
  274. var obj={
  275. title:that.familyname,
  276. category_id:that.listflall[that.activeIndex].id,
  277. memberinfo_id:that.itemuser.id,
  278. ids:newids,
  279. scene_id:that.list1all[that.activeIndex1].id,
  280. id:that.id*1
  281. }
  282. var url="/api/Collocation/customizedUpdateCollocation"
  283. }
  284. myRequest({
  285. url: url,
  286. method:'post',
  287. data:obj
  288. }).then(res => {
  289. console.log(res.data)
  290. if (res.data.code == 200) {
  291. setTimeout(function(){
  292. let pages = getCurrentPages(); // 当前页面
  293. let beforePage = pages[pages.length - 2]; // 前一个页面
  294. uni.navigateBack({
  295. delta: 1,
  296. success: function() {
  297. beforePage.$vm.shuaxin()
  298. }
  299. });
  300. },2000)
  301. that.$refs.toast.show({model:'success',label:res.data.msg})
  302. }else{
  303. that.$refs.toast.show({model:'error',label:res.data.msg})
  304. }
  305. })
  306. console.log(obj)
  307. },
  308. jiarufuFun(data){
  309. // uni.navigateTo({
  310. // url: "/pages/shopdetail/index",
  311. // })
  312. console.log(data)
  313. },
  314. },
  315. }
  316. </script>
  317. <style lang="scss">
  318. /deep/ .tm-menubars .body{
  319. background-color: #1b1b1b !important;
  320. }
  321. /deep/ .zhuti{padding: 10px 10px;}
  322. /deep/ .kuang{margin:0 !important;padding: 0px !important;}
  323. .chuanda{width: 100%;margin-top:10px;}
  324. .shuru{background: #0D0D0D;padding: 10px;margin-top: 20px;}
  325. /deep/ .shuru .grey-darken-5{
  326. background-color: #0d0d0d!important;
  327. padding: 0px !important;
  328. }
  329. .shuru{border:1px solid #303030;border-radius: 10px;}
  330. /deep/ .shuru .text-primary.bk{color:#303030 !important;}
  331. /deep/ .shuru .border-grey-darken-4-b-1{border-bottom:none !important;}
  332. /deep/ .qiehuan .tm-tabs-con-item-border{display: none;}
  333. /deep/ .qiehuan .tm-tabs-con-item-text{background: #303440;height: 26px;line-height: 26px;
  334. padding-left: 14px;padding-right: 14px;margin-top: 17%;border-radius: 20px;margin-left: 10px;}
  335. /deep/ .qiehuan .text-white{
  336. font-size: 14px;
  337. background: #0178FD;
  338. height: 26px;
  339. vertical-align: middle;
  340. line-height: 26px;
  341. border-radius: 20px;
  342. padding-left: 14px;
  343. padding-right: 14px;
  344. margin-top: 17%;
  345. }
  346. .biaoti view{width:5px;height:19px;background: #0178FD;float: left;border-radius: 10px;}
  347. /deep/ .qiehuan1 .text-primary{color: white !important;}
  348. /deep/ .jiaoxi{margin:0 !important;padding: 8px !important;}
  349. /deep/ .shangpin .white.bk{background-color:#1b1b1b!important;}
  350. /deep/ .shangpin .tm-cartCellListFood{padding: 0px 0px 5px 0px !important;
  351. margin-top: 5px !important;border-bottom: 1px solid #1B1B1B;}
  352. /deep/ .shangpin .border-t-1.bk{border-top:1px solid #1b1b1b!important;}
  353. /deep/ .shangpin .round-3{width:120px !important;height:110px !important;}
  354. /deep/ .shangpin .tm-cartCellListFood-img{width:120px !important;height:110px !important;}
  355. /deep/ .shangpin .title{color: white !important;}
  356. /deep/ .shangpin .text-red{color: white !important;}
  357. .sao{width: 88%;display: block;margin: 0 auto;padding-bottom: 60px;margin-top: 20px;}
  358. .goumai{background: #1B1B1B;margin-bottom: 10px;}
  359. .anniu{width: 70%;margin: 0 auto;margin-top: 20px;padding-bottom: 30px;}
  360. /deep/ .anniubaocun{width: 100%;}
  361. /deep/ .anniubaocun .flex-center{width: 100% !important;}
  362. </style>