index.vue 10 KB

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