index.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  1. <style>
  2. .m-app{width:100vw}
  3. /* 头部 */
  4. .app-header{width:100%;position:fixed;top:0px;left:0px;z-index: 10;background: transparent;}
  5. .app-header-bg{background: #ffffff;}
  6. .mp-padding{width:100%;height:50px;}
  7. button.item-back-btn{width:30px;height:30px;}
  8. button.item-back-btn image{width:30px;height:30px;}
  9. .mp-title{color:transparent;font-size: 16px;font-weight: 700;text-align: center;width:100%;height:50px;line-height: 50px;position: relative;}
  10. .mp-title text{ width: 80%; white-space: nowrap;text-overflow: ellipsis;overflow: hidden;word-break: break-all;display: inline-block;}
  11. .mp-title button.item-back-btn{position: absolute;left:12px;top:10px}
  12. .app-header-bg .mp-title{color:#333333;}
  13. /* 滚动内容区域 */
  14. scroll-view.mid-body{width:100vw;height:calc(100vh - 50px);}
  15. /* 轮播 */
  16. .item-swiper{width:100vw;height:100vw;background:#ffffff;position: relative;}
  17. .swiper-count{height:24px;line-height: 24px; position: absolute;right:15px;bottom:15px;padding: 0px 10px;border-radius: 12px;background: rgba(0,0,0,0.5);}
  18. .swiper-count text{color:#f7f7f7;font-size: 14px;height:14px;line-height: 14px;}
  19. .swiper-count text:first-child{font-weight: 700;}
  20. swiper{width:100vw;height:100vw;}
  21. swiper-item{width:100vw;height:100vw;}
  22. image.swiper-item-img{width:100vw;height:100vw;}
  23. .item-transparent{background: transparent;}
  24. /** 商品新详情**/
  25. .goods-info{background: #fff;margin: 10px;padding: 8px;border-radius: 10px;}
  26. .goods-info .price-info{}
  27. .goods-info .price-info .price{color: #fd3b39;font-size: 28px;font-weight: 600;}
  28. .goods-info .price-info .price text{color: #fd3b39;font-size: 16px;font-weight: 400;}
  29. .goods-info .price-info .old-price{margin-left: 10px;color: #98999A;font-size: 14px;font-weight: 400;text-decoration: line-through;}
  30. .goods-info .title{color: #333;font-size: 16px;font-weight: 600;}
  31. .goods-info .foot{margin-top: 10px;}
  32. .goods-info .address{color: #ACACAC;font-size: 14px;font-weight: 400;}
  33. .goods-info .add-icon{width: 14px;height: 14px;margin-right: 3px;}
  34. .goods-info .sales{color: #ACACAC;font-size: 14px;font-weight: 400;}
  35. .green-info{border:1px solid #fd3b39;border-radius: 10px; padding: 5px;background: rgba(1, 149, 96, 0.2);margin-top: 10px;}
  36. .green-info image{width: 20px;height: 20px;margin-right: 4px;}
  37. .green-info .tinfo{font-size: 12px;color: #fd3b39;}
  38. .green-info .tinfo text{font-weight: bold;}
  39. /* 属性规格 */
  40. .item-prop{padding: 0px 15px;background: #ffffff;margin: 10px;border-radius: 10px;}
  41. .item-prop-list{width:100%;height:45px;}
  42. .item-prop-title{width:48px;text-align: left;font-size: 14px;color:#BFBFBF;}
  43. button.item-prop-btn{width:calc(100% - 48px);height:45px;}
  44. button.item-prop-btn text{text-align: left;font-size: 14px;color:#333333;width:calc(100% - 14px);height:14px;line-height: 14px;}
  45. button.item-prop-btn image{width:14px;height:14px}
  46. .item-service{padding: 15px 12px;width:calc(100% - 24px);margin-top: 10px;background: #ffffff;}
  47. .item-service-list{width:100%;margin-top: 15px;}
  48. .item-service-list:first-child{margin-top: 0px;}
  49. .item-service-title{width:42px;text-align: left;font-size: 13px;color:#666666;}
  50. .item-service-val{width:calc(100% - 42px);text-align: left;font-size: 13px;color:#333333;}
  51. .item-service-val text.red-text{color:#ff383e}
  52. /* 商品评价 */
  53. .item-evaluate{background: #ffffff;padding: 0px 15px;width:calc(100% - 30px);margin-top: 8px;}
  54. button.evaluate-btn{padding: 10px 0;}
  55. button.evaluate-btn text{text-align: center;color:#A8A8A8;font-size: 14px;height:14px;line-height: 14px;}
  56. button.evaluate-btn text.evaluate-title{color:#333333;font-size: 15px;line-height: 15px;height:15px;text-align: left;font-weight: 700;}
  57. button.evaluate-btn image{width:14px;height:14px;margin-left: 4px;}
  58. .evaluate-show{width:100%;}
  59. .evaluate-list{padding-top:8px;padding-bottom: 8px;border-bottom:1px solid #EEEEEE;}
  60. .evaluate-list:last-child{border-bottom:none;}
  61. .evaluate-user{width:100%;}
  62. .evaluate-avatar{height:32px;width:32px;border-radius: 16px;overflow: hidden;}
  63. .evaluate-avatar image{height:32px;width:32x;}
  64. .evaluate-info{height:40px;width:calc(100% - 40px - 6px);margin-left: 6px;}
  65. .evaluate-nickname{width:100%;color:#333333;font-size: 14px;text-align: left;height:14px;line-height: 14px;}
  66. .evaluate-star{height:12px;margin-top: 4px;}
  67. image.evaluate-star-img{width:12px;height:12px;margin-right: 2px;}
  68. .evaluate-msg{margin-top: 8px;text-align: left;color:#333333;font-size: 14px;line-height: 20px;font-weight: 400;}
  69. .evaluate-img{padding-top: 10px;}
  70. .evaluate-img-list{width:75px;height:75px;overflow: hidden; background: #F1F1F1;margin-right: 10px;}
  71. .evaluate-img-list image,.evaluate-img-list img{width:75px}
  72. image.doctor-star-img{width:12px;height:12px;margin-right: 2px;}
  73. /* 商品详情 */
  74. .item-desc{width:100%;}
  75. .item-desc-title{width:100%;height:40px;}
  76. .desc-title{font-size: 15px;height:15px;line-height: 15px;text-align: center;color:#333333;margin: 0px 10px;}
  77. .desc-title-left{width:40px;height:1px;background: #E6E6E6}
  78. .desc-title-right{width:40px;height:1px;background: #E6E6E6}
  79. .item-desc-img{width:100%}
  80. .item-desc-img image{width:100%}
  81. .item-desc-img text{ position: absolute; width: 100%; text-align: center; font-size: 1px; color: #ccc;}
  82. /* app底部 */
  83. .app-footer{width:100vw;height:50px;background: #ffffff;position: fixed;bottom:0px;left:0px;z-index: 2;}
  84. button.app-footer-nav{width:50px;height:50px; position: relative;}
  85. button.app-footer-nav image{width:25px;height:25px}
  86. button.app-footer-nav text{font-size: 12px;height:12px;line-height: 12px;width:100%;text-align: center;margin-top: 4px;color:#323334}
  87. button.app-footer-nav text.love-hit{ color: #f1851e;}
  88. .cart-count{position: absolute; top: -4px; right:7px; width: 15px;height: 15px;border-radius: 50%;text-align:center;line-height:15px;background: #FA4171; font-size: 12px; color: #fff;}
  89. .app-footer{
  90. background: hsla(0, 0%, 100%, .9);
  91. box-shadow: 0 0 11px 0 rgba(0, 0, 0, .5);
  92. }
  93. button.app-footer-btn{background: #fd3b39;height: 56px;width: 100%;text-align: center;line-height: 56px;color: #fff;font-size: 16px;}
  94. button.app-footer-btn-max{height:40px;line-height: 40px;width:calc(90% - 115px);text-align: center;font-size: 15px;color:#ffffff;font-weight: 700;background:linear-gradient(180deg,#f8b52b 0%,#f2861f 100%);border-radius:10px;}
  95. button.app-footer-btn-max.no-buy{height:40px;line-height: 40px;width:calc(90% - 115px);text-align: center;font-size: 15px;color:#ffffff;font-weight: 700;background:rgba(0,0,0,0.5);border-radius:10px;}
  96. /* 属性弹窗 */
  97. .pop-prop{position: fixed; width: 100%; height: 100%; top: 0; left: 0; z-index: 999;}
  98. .pop-prop-body{position:absolute; bottom: 0; width: 100%; background: #fff; border-radius: 8px 8px 0 0;}
  99. .pop-prop-close{height:40px;width:40px;position: absolute;top:0px;right:0px;}
  100. .pop-prop-close image{ width: 20px; height: 20px;}
  101. /* 弹窗 */
  102. button.app-foot-btn{height:40px;line-height: 40px;width:100%;text-align: center;font-size: 14px;color:#ffffff;font-weight: 400;
  103. background:#fd3b39;border-radius: 20px;}
  104. .pop-win{position: fixed; width: 100%; height: 100%; top: 0; left: 0; z-index: 9;}
  105. .pop-bg{ position: absolute; top: 0; left: 0; background: rgba(0,0,0,0.5); width: 100%; height: 100%;}
  106. .pop-win-inner{ position:absolute; bottom: 0; width: 100%; background: #fff; border-radius: 8px 8px 0 0;}
  107. .pop-win-body{ padding: 15px;}
  108. .pop-win-bg image{ width: 80px; height: 80px;}
  109. .pop-win-lg{ margin-left: 8px; width: calc(100vw - 138px );}
  110. .pop-win-lg-title{ font-size: 14px; color:#333333;}
  111. .pop-win-log-price{ font-size: 20px; color:#fd3b39;font-weight: 700;}
  112. .pop-win-log-price text{ font-size: 14px;font-weight:normal}
  113. .pop-win-close image{ width: 20px; height: 20px;}
  114. .pop-br{ height: 1px; background: #F1F1F1; margin: 10px 0;}
  115. .pop-win .sku{ margin: 8px 0;}
  116. .pop-win .sku-name{ font-size:14px;color:#333333}
  117. .pop-win .sku-value{ margin:10px 0;}
  118. .pop-win .sku-value button{border-radius: 10px; background: #eeeeee;color:#333333; padding: 10px; margin-right: 6px;font-size: 12px;margin-bottom: 10px;}
  119. .pop-win .buy{ margin-top: 32px; font-size: 14px;}
  120. button.buy-ad-btn{ width: 60upx; height: 60upx; color: #333; font-size: 20px; line-height: 48upx; text-align: center; background: #F6F6F6; border: 1px solid #CFCFCF; border-radius: 3px;}
  121. button.buy-ad-btn.jdd{ border-radius:3px 0 0 3px;}
  122. button.buy-ad-btn.add{ border-radius:0px 3px 3px 0px;}
  123. .buy-input{ border-top: 1px solid #CFCFCF; text-align: center; color: #333333; font-size: 12px;border-bottom: 1px solid #CFCFCF; height: 56upx; width: 100upx;}
  124. .sku-value button.active{color: #ffffff;background: #fd3b39;}
  125. .pop-win-kc{ font-size: 12px; color: #666666;}
  126. .pop-win-xz{ font-size: 12px;}
  127. </style>
  128. <template>
  129. <view class="m-app">
  130. <view class="app-header" :class="topShow ? 'app-header-bg' : ''">
  131. <view class="top-bar" :style="'height:' + barHeight + 'px'"></view>
  132. <view class="mp-padding fx-r fx-bc" >
  133. <view class="mp-title">
  134. <button class="nt item-back-btn fx-r fx-bc fx-ac" @tap="tapBack">
  135. <image src="/static/img/icon_item_back.png"></image>
  136. </button>
  137. <text>{{data.title}}</text>
  138. </view>
  139. </view>
  140. </view>
  141. <scroll-view class="mid-body clearfix" scroll-y="true" @scrolltolower="loadMoreData" @scroll="tapScroll">
  142. <view class="item-swiper">
  143. <swiper autoplay='true' @change="tapSwiperChange" indicator-dots="true" indicator-color='rgba(255,255,255,.3)' indicator-active-color='rgba(255,255,255,1)'>
  144. <swiper-item @tap="tapPhone('img',index)" v-for="(item,index) in data.imgs">
  145. <image class="swiper-item-img" :src="item" mode="aspectFill"></image>
  146. </swiper-item>
  147. </swiper>
  148. <view v-if="data.is_stepinto == 1" style="background: #333; color: #FFF; border-radius: 4px;font-size: 10px; margin-left: 4px;padding: 0px 4px;position: absolute;bottom: 10px;left: 10px;">跨境产品</view>
  149. <view class="swiper-count fx-r fx-bc"><text>{{swiperCurrent+1}}</text><text>/{{data.imgs.length?data.imgs.length:''}}</text></view>
  150. </view>
  151. <!-- 商品信息 -->
  152. <view class="goods-info">
  153. <view class="price-info fx-r fx-bc">
  154. <view class="price" v-if="sysData.is_audit == 0"><text>¥积分</text>{{ data.commission }}</view>
  155. <view class="price" v-else><text>¥参考价</text>{{ data.commission }}</view>
  156. </view>
  157. <view class="title">{{data.title}}</view>
  158. <view class="foot fx-r">
  159. <view class="address fx-r fx-bc">
  160. <image class="add-icon" src="/static/img/shop-address.png"></img>
  161. <text v-if="data.freight > 0">快递:{{data.freight}}</text>
  162. <text v-else>免邮费</text>
  163. </view>
  164. <view class="fx-g1"></view>
  165. <view class="sales">销量 {{utils.sales(data.sales)}}</view>
  166. </view>
  167. </view>
  168. <view class="item-prop">
  169. <view class="item-prop-list fx-r fx-bc">
  170. <view class="item-prop-title">选择</view>
  171. <button class="nt item-prop-btn fx-r fx-bc" @tap="tapCart">
  172. <text class="shenlueStyle" v-if="selData.skuStr == ''">选择商品规格</text>
  173. <text class="shenlueStyle" v-if="selData.skuStr != ''">{{selData.skuStr}}</text>
  174. <image src="/static/img/ic_next.png"></image>
  175. </button>
  176. </view>
  177. </view>
  178. <!-- 商品详情 -->
  179. <view class="item-desc">
  180. <view class="item-desc-title fx-r fx-bc fx-ac">
  181. <text class="desc-title-left"></text>
  182. <text class="desc-title">详情</text>
  183. <text class="desc-title-right"></text>
  184. </view>
  185. <view class="item-desc-img">
  186. <image @tap="tapPhone('descImg',index)" mode="widthFix" :src="item" v-for="(item,index) in data.imgDesc" />
  187. </view>
  188. </view>
  189. </scroll-view>
  190. <!-- app底部 -->
  191. <view class="app-footer fx-r fx-bc" v-if="sysData.is_audit == 0">
  192. <button @tap="tapBuy" v-if="data.isShow == 1" class="nt app-footer-btn bg-buy">立即兑换</button>
  193. <button v-if="data.isShow == 0" class="nt app-footer-btn-max no-buy">已下架</button>
  194. </view>
  195. <view class="app-footer fx-r fx-bc" v-else>
  196. <button @tap="tapXu" class="nt app-footer-btn bg-buy">询价</button>
  197. </view>
  198. <!-- 属性规格弹窗 -->
  199. <view class="pop-prop" v-if="isProp">
  200. <view class="pop-bg" @tap="tapPopClose"></view>
  201. <view class="pop-prop-body">
  202. <view class="pop-prop-close fx-r fx-bc fx-ac" @tap="tapPopClose">
  203. <image src="/static/img/m_close.png"></image>
  204. </view>
  205. <view class="item-service" v-if="data.inputPids.length > 0">
  206. <view class="item-service-list fx-r" v-for="(item,index) in data.inputPids">
  207. <view class="item-service-title">{{item.name}}:</view>
  208. <view class="item-service-val">{{item.value}}</view>
  209. </view>
  210. </view>
  211. </view>
  212. </view>
  213. <!-- 购买弹窗 -->
  214. <view class="pop-win" v-if="isShow">
  215. <view class="pop-bg" @tap="tapPopClose"></view>
  216. <view class="pop-win-inner">
  217. <view class="pop-win-body">
  218. <view class="fx-r">
  219. <view class="pop-win-bg">
  220. <image @tap="tapPhone2" :src="selData.img"></image>
  221. </view>
  222. <view class="pop-win-lg">
  223. <view class="pop-win-lg-title">{{data.title}}</view>
  224. <view class="pop-win-log-price"><text>¥</text>{{selData.commission}}</view>
  225. <view class="pop-win-kc">库存:{{selData.proCount}}件</view>
  226. <view class="pop-win-xz" v-if="selData.skuStr != ''">已选:{{selData.skuStr}}</view>
  227. </view>
  228. <view class="pop-win-close" @tap="tapPopClose">
  229. <image src="/static/img/m_close.png"></image>
  230. </view>
  231. </view>
  232. <!--选择属性-->
  233. <view class="pop-br"></view>
  234. <view>
  235. <view class="sku" v-for="(item,index) in data.sku.skuValue">
  236. <view class="sku-name">{{item.name}}</view>
  237. <scroll-view scroll-y="true" style="max-height: 150px;">
  238. <view class="sku-value fx-r">
  239. <button @tap="tapSku(index,index2)" :class="(selData.sku[index] == index2) ? 'active' : ''" class="nt" v-for="(item2,index2) in item.data">{{item2.name}}</button>
  240. </view>
  241. </scroll-view>
  242. </view>
  243. </view>
  244. <view class="buy fx-r fx-bc fx-ac">
  245. <view class="fx-g1">数量</view>
  246. <view class="fx-r" v-if="data.is_package == 0">
  247. <button @tap="tapAdCount(-1)" class="nt buy-ad-btn jdd">-</button>
  248. <input type="number" v-model="selData.count" @input="tapInput" class="buy-input"/>
  249. <button @tap="tapAdCount(1)" class="nt buy-ad-btn add">+</button>
  250. </view>
  251. <view class="fx-r" v-else>
  252. x{{ selData.count }}
  253. </view>
  254. </view>
  255. </view>
  256. <view class="fx-r" style="padding: 15px;">
  257. <button @tap="tapSubmit" class="nt app-foot-btn ">确定</button>
  258. </view>
  259. </view>
  260. </view>
  261. </view>
  262. </template>
  263. <script>
  264. import {mapState,mapMutations } from 'vuex';
  265. var idsValue = {};
  266. var buyType = "";
  267. export default {
  268. computed: mapState(['user','sysData']),
  269. data() {
  270. return {
  271. id : 0,//产品ID
  272. topShow:false,
  273. model:false,
  274. cartCount:0,//购物车数量
  275. swiperCurrent:0,
  276. barHeight:0,
  277. data:{
  278. inputPids:[],
  279. title : '加载中..',
  280. isLove:0,
  281. commission : 0,
  282. auctionPoint :0,
  283. price : 0,
  284. freight : 0,
  285. sales : 0,
  286. imgDesc:[],
  287. imgs:[],
  288. msgData:[]
  289. },
  290. selData:{//选择款数据
  291. count:1,
  292. },
  293. isShow:false,//弹出选择项目
  294. isProp:false//属性弹窗
  295. }
  296. },
  297. onLoad(option){
  298. this.id = option.id || 0;
  299. uni.setNavigationBarTitle({title:'加载中..'});
  300. this.barHeight = this.$device.statusBarHeight;
  301. this.initView();
  302. },
  303. methods: {
  304. ...mapMutations(['checkUserLogin']),
  305. /**
  306. * 加载更多
  307. * @param {Object} e
  308. */
  309. loadMoreData: function(e) {
  310. console.log(e)
  311. },
  312. /**
  313. * 下拉下载
  314. * @param {Object} e
  315. */
  316. tapScroll:function(e){
  317. let scrollTop=e.detail.scrollTop;
  318. if(scrollTop < 120 && this.topShow)
  319. this.topShow = false
  320. if(scrollTop > 120 && !this.topShow)
  321. this.topShow = true;
  322. return;
  323. },
  324. tapSwiperChange:function(ev){
  325. this.swiperCurrent = ev.detail.current;
  326. },
  327. /**
  328. * 输入值
  329. * @param {Object} ev
  330. */
  331. tapInput:function(ev){
  332. var value = ev.detail.value;
  333. if(value != '') {
  334. //this.selData.count = value;
  335. }
  336. },
  337. /**
  338. * 购物车数量添加
  339. * @param {Object} type
  340. */
  341. tapAdCount:function(type){
  342. var count = this.data.count;
  343. //添加
  344. if(type > 0) {
  345. if(type >= count) {
  346. this.utils.showAlert({title: '系统提示',content: '库存不足了!'});
  347. }
  348. this.selData.count ++;
  349. }
  350. //想减
  351. if(type < 0) {
  352. if(this.selData.count <= 1) {
  353. return;
  354. }
  355. this.selData.count--;
  356. }
  357. },
  358. /**
  359. * sku属性值
  360. * @param {Object} pid
  361. * @param {Object} vid
  362. */
  363. tapSku:function(pid,vid){
  364. this.$forceUpdate();
  365. this.selData.sku[pid] = vid;
  366. var idsAr = [],skuStrAr = [],isOverSku = true;
  367. for(var i in this.selData.sku) {
  368. if(this.selData.sku[i] < 0) {
  369. isOverSku = false;
  370. continue;
  371. }
  372. var skuValue = this.data.sku.skuValue[i];
  373. idsAr.push(skuValue.data[this.selData.sku[i]].id);
  374. skuStrAr.push(skuValue.name + ":" + skuValue.data[this.selData.sku[i]].name);
  375. }
  376. //是否未点选完毕
  377. if(!isOverSku) {
  378. return;
  379. }
  380. var ids = idsAr.join(':');
  381. idsValue = null;
  382. //遍历所需要的数据
  383. for(var i in this.data.sku.skuIds) {
  384. var d = this.data.sku.skuIds[i];
  385. if(d.skuId == ids) {
  386. idsValue = d;
  387. break;
  388. }
  389. }
  390. this.$forceUpdate();
  391. this.selData.skuIds = ids;
  392. this.selData.skuStr = skuStrAr.join(',');
  393. //idsValue数据
  394. if(idsValue != null) {
  395. this.selData.commission = idsValue.commission;
  396. this.selData.proCount = idsValue.count;
  397. if(idsValue.img == '') {
  398. this.selData.img = this.data.imgs[0];
  399. } else {
  400. this.selData.img = idsValue.img;
  401. }
  402. }
  403. },
  404. /**
  405. * 打开购物车
  406. */
  407. tapCart:function(){
  408. this.isShow = true;
  409. buyType = "cart";
  410. },
  411. /**
  412. *
  413. */
  414. tapBuy:function(){
  415. if(this.user == null) {
  416. uni.navigateTo({ url:"../login/login"});
  417. return;
  418. }
  419. buyType = "buy";
  420. this.isShow = true;
  421. },
  422. //打开属性弹窗
  423. tapOpenProp:function(){
  424. this.isProp = true;
  425. },
  426. /**
  427. * 关闭弹出框
  428. */
  429. tapPopClose:function(){
  430. this.isShow = false;
  431. this.isProp = false;
  432. },
  433. /**
  434. * 选择数据
  435. */
  436. tapSubmit:function(){
  437. this.checkUserLogin({page:this});
  438. if(!this.utils.isDefine(this.user)) {
  439. uni.navigateTo({ url:"../login/login"});
  440. return;
  441. }
  442. this.submitPost();
  443. },
  444. /**
  445. * 提交数据
  446. */
  447. submitPost:function(){
  448. var that = this;
  449. var ids = this.selData.skuIds;
  450. var idsAr = this.selData.skuIds.split(':');
  451. var count = this.selData.count;
  452. //是否[有规格未选择]
  453. if(this.data.sku.skuValue.length > 0) {
  454. for(var i in this.data.sku.skuValue){
  455. var skuValue = this.data.sku.skuValue[i];
  456. var bool = false;
  457. for(var i1 in skuValue.data) {
  458. for(var i2 in idsAr) {
  459. if(idsAr[i2] == skuValue.data[i1].id) {
  460. bool = true;
  461. }
  462. }
  463. }
  464. if(!bool) {
  465. this.utils.showAlert({title: '系统提示',content: "请选择" + skuValue.name});
  466. return;
  467. }
  468. }
  469. }
  470. //判断数量是否超过最大值
  471. if(count > this.selData.maxCount) {
  472. this.utils.showAlert({title: '系统提示',content: "起订数量超过库存数量!"});
  473. return;
  474. }
  475. //购买
  476. if(buyType == 'buy') {
  477. var parm = [];
  478. parm.push({
  479. id : this.id,
  480. count : this.selData.count,
  481. skuIds : ids
  482. });
  483. console.log(parm);
  484. uni.navigateTo({url: "/pages/user/buy/balance?data=" + JSON.stringify(parm)});
  485. }
  486. },
  487. /**
  488. * 加入收藏成功
  489. */
  490. tapLove:function(){
  491. if(!this.utils.isDefine(this.user)) {
  492. uni.navigateTo({ url:"../login/login"});
  493. return;
  494. }
  495. var that = this;
  496. uni.showLoading({title: '加入收藏中..'});
  497. var post = {};
  498. post.id = this.id;
  499. post.type = this.data.isLove == 1 ? 0 : 1;
  500. this
  501. .request
  502. .post("userGoodsLover",post)
  503. .then(res=>{
  504. uni.hideLoading();
  505. if(res.code == 200) {
  506. that.$forceUpdate();
  507. if(post.type == 1)
  508. this.utils.Tip("收藏成功");
  509. else
  510. this.utils.Tip("取消成功");
  511. that.data.isLove = post.type;
  512. } else {
  513. this.utils.showAlert({title: '系统提示',content: res.msg});
  514. }
  515. })
  516. .catch(err=>{
  517. uni.hideLoading();
  518. this.utils.showAlert({title: '系统提示',content: "加入失败,请稍后在尝试"});
  519. });
  520. },
  521. /**
  522. * 获取配置数据
  523. */
  524. initView: function() {
  525. var that = this;
  526. uni.showLoading({title: '获取数据中..'});
  527. var post = {};
  528. post.id = this.id;
  529. this
  530. .request
  531. .post("goodsItem",post)
  532. .then(res=>{
  533. uni.hideLoading();
  534. if(res.code == 200) {
  535. this.data = res.data;
  536. var sku = [];
  537. this.selData = {
  538. title : res.data.title,
  539. img : res.data.imgs[0],//图片
  540. commission : res.data.commission,//当前价格
  541. count : 1,//购物数量
  542. sku : sku,//点选SKU
  543. skuIds : "",//选择sku值
  544. proCount : res.data.count,//库存量
  545. skuStr : "",//已选的SKU
  546. };
  547. uni.setNavigationBarTitle({title:res.data.title});
  548. } else {
  549. this.utils.showAlert({title: '系统提示',content: res.msg});
  550. }
  551. })
  552. .catch(err=>{
  553. console.log(err);
  554. uni.hideLoading();
  555. this.utils.showAlert({title: '系统提示',content: "加载失败,重新点击尝试!"});
  556. });
  557. },
  558. /**
  559. * 打开详情
  560. * @param {Object} type
  561. * @param {Object} index
  562. */
  563. tapPhone:function(type,index){
  564. var ImgAr = [];
  565. if(type == 'img') {
  566. ImgAr = this.data.imgs;
  567. }
  568. if(type == 'descImg') {
  569. ImgAr = this.data.imgDesc;
  570. }
  571. uni.previewImage({
  572. current:index,
  573. urls:ImgAr
  574. });
  575. },
  576. /**
  577. * 打开其他主图2
  578. */
  579. tapPhone2:function(){
  580. var ImgAr = [this.selData.img];
  581. uni.previewImage({
  582. current:0,
  583. urls:ImgAr
  584. });
  585. },
  586. /**
  587. * 打开其他页面
  588. * @param {Object} ev
  589. */
  590. tapOpen: function(ev) {
  591. let url = ev.currentTarget.dataset.url;
  592. this.utils.navigateTo(url);
  593. },
  594. /**
  595. * 返回首页
  596. */
  597. tapHome:function(){
  598. uni.switchTab({
  599. url : "../index/index"
  600. });
  601. },
  602. /**
  603. * 返回上一页
  604. */
  605. tapBack: function() {
  606. uni.navigateBack({
  607. delta: 1
  608. });
  609. },
  610. /**
  611. * 打开评价图
  612. * @param {Object} index
  613. * @param {Object} index2
  614. */
  615. tapMsgImg:function(index,index2){
  616. var ImgAr = this.data.msgData[index].imgs;
  617. // #ifdef H5
  618. this.$wx.previewImage({
  619. current:index2,
  620. urls:ImgAr
  621. });
  622. // #endif
  623. // #ifndef H5
  624. uni.previewImage({
  625. current:index2,
  626. urls:ImgAr
  627. });
  628. // #endif
  629. },
  630. tapXu:function(){
  631. // #ifdef APP-PLUS
  632. this.$store.dispatch('permission/requestPermissions', 'CALL_PHONE').then(res => {
  633. console.log(res);
  634. if(res !== 1) return;
  635. uni.makePhoneCall({
  636. phoneNumber:"18967672398",
  637. fail:(res)=>{
  638. uni.showModal({content:JSON.stringify(res)});
  639. },
  640. complete:(xx) => {
  641. }
  642. });
  643. });
  644. return;
  645. // #endif
  646. uni.makePhoneCall({
  647. phoneNumber:"18967672398",
  648. fail:(res)=>{
  649. uni.showModal({content:JSON.stringify(res)});
  650. },
  651. complete:(xx) => {
  652. }
  653. });
  654. }
  655. }
  656. }
  657. </script>