app-recommended-product.vue 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067
  1. <template>
  2. <view class="app-recommended-product">
  3. <view class="app-display-classification" v-if="showCat">
  4. <scroll-view class="app-scroll-view dir-left-nowrap" scroll-x scroll-with-animation>
  5. <text class="app-nav-item" @click="change(index)"
  6. :class="{'app-active-current': catStyle === 1 && activeCurrent === index,
  7. 'app-active-current-round': catStyle === 2 && activeCurrent === index,
  8. 'app-current-round': catStyle === 2
  9. }"
  10. :key="index"
  11. v-for="(item, index) in catList"
  12. >{{item.menuName}}</text>
  13. </scroll-view>
  14. </view>
  15. <view class="app-content" v-if="!showCat">
  16. <!-- 列表模式 -->
  17. <view class="app-list-mode" v-if="listStyle === -1">
  18. <view :class="{'app-border': goodsStyle === 2}" :key="index" v-for="(item, index) in list">
  19. <app-form-id @click="jump(item)">
  20. <view class="app-item dir-left-nowrap">
  21. <image class="app-icon" :src="goodsTagPicUrl" v-if="showGoodsTag"></image>
  22. <image class="app-image" :mode="fill === 1 ? 'scaleToFill' : fill === 2 ? 'aspectFit': ''" :src="item.cover_pic"></image>
  23. <view class="app-item-content dir-top-nowrap" :class="{'main-right': showGoodsName === false}">
  24. <text class="app-name" v-if="showGoodsName">{{item.name}}</text>
  25. <view class="app-price-button dir-left-nowrap" :class="{'main-between': showGoodsPrice, 'main-right': !showGoodsPrice}">
  26. <text v-if="showGoodsPrice" class="app-text">{{item.price_content}}</text>
  27. <template v-if="showBuyBtn">
  28. <button v-if="buyBtn === 'text'"
  29. @click.stop="buyProduct(item)"
  30. :class="{
  31. 'app-button-filling': buyBtnStyle === 1,
  32. 'app-button-line' : buyBtnStyle === 2 ,
  33. 'app-button-fillet' : buyBtnStyle === 3,
  34. 'app-button-rounded-lines': buyBtnStyle === 4,
  35. }"
  36. >{{buyBtnText}}</button>
  37. <icon class="app-icon-button app-shopping-cart"
  38. @click.stop="buyProduct(item)"
  39. v-else-if="buyBtn === 'cart'"
  40. ></icon>
  41. <icon class="app-icon-button app-add-to"
  42. @click.stop="buyProduct(item)"
  43. v-else-if="buyBtn === 'add'"
  44. ></icon>
  45. </template>
  46. </view>
  47. </view>
  48. </view>
  49. </app-form-id>
  50. </view>
  51. </view>
  52. <!-- 左右滑动 -->
  53. <view class="app-swipe-left-right" v-if="listStyle === 0">
  54. <scroll-view class="scroll-view" scroll-with-animation scroll-x>
  55. <view class="app-item" :class="{'app-border': goodsStyle === 2 || goodsStyle === 4}" v-for="(item, index) in list" :key="index">
  56. <app-form-id @click="jump(item)">
  57. <image class="app-icon" :src="goodsTagPicUrl" v-if="showGoodsTag"></image>
  58. <image class="app-image" :mode="fill === 1 ? 'scaleToFill' : fill === 2 ? 'aspectFit': ''" :src="item.cover_pic"></image>
  59. <view class="app-price-button-name dir-top-nowrap">
  60. <text v-if="showGoodsName" class="app-name" :class="{'app-name-goods-style': goodsStyle === 3 || goodsStyle === 4}">{{item.name}}</text>
  61. <view class="app-price-button dir-left-nowrap cross-bottom"
  62. :class="{
  63. 'app-price-goods-style': goodsStyle === 3 || goodsStyle === 4,
  64. 'main-right': showGoodsPrice === false
  65. }">
  66. <text v-if="showGoodsPrice" class="app-price" :class="{'app-price-goods-style': goodsStyle === 3 || goodsStyle === 4}">{{item.price_content}}</text>
  67. <template v-if="goodsStyle !== 3 && goodsStyle !== 4">
  68. <icon class="app-icon-button app-shopping-cart"
  69. @click.stop="buyProduct(item)"
  70. v-if="buyBtn === 'cart'"
  71. ></icon>
  72. <icon class="app-icon-button app-add-to"
  73. @click.stop="buyProduct(item)"
  74. v-else-if="buyBtn === 'add'"
  75. ></icon>
  76. </template>
  77. </view>
  78. </view>
  79. </app-form-id>
  80. </view>
  81. </scroll-view>
  82. </view>
  83. <!-- 一行一个 -->
  84. <view class="app-one-per-line" v-if="listStyle === 1">
  85. <view class="app-item" :class="{'app-border': goodsStyle === 2 || goodsStyle === 4, 'app-square': goodsCoverProportion === '1-1',
  86. 'app-rectangle': goodsCoverProportion === '3-2'
  87. }" v-for="(item, index) in list" :key="index">
  88. <app-form-id @click="jump(item)">
  89. <image class="app-icon" :src="goodsTagPicUrl" v-if="showGoodsTag"></image>
  90. <image class="app-image"
  91. :mode="fill === 1 && goodsCoverProportion === '3-2'? 'center' :goodsCoverProportion === '3-2' && fill === 2 ? 'aspectFit': fill === 1 && goodsCoverProportion === '1-1' ? 'scaleToFill' : goodsCoverProportion === '1-1' && fill === 2 ? 'scaleToFill' : ''"
  92. :class="{
  93. 'app-square-image': goodsCoverProportion === '1-1',
  94. 'app-rectangle-image': goodsCoverProportion === '3-2',
  95. }"
  96. :src="item.cover_pic"
  97. ></image>
  98. <text class="app-text" :style="{textAlign: goodsStyle === 3 ? 'center' : ''}" v-if="showGoodsName">{{item.name}}</text>
  99. <view v-if="showBuyBtn && showGoodsPrice"
  100. class="app-button-price dir-left-nowrap cross-center"
  101. :class="{'main-between': goodsStyle !== 3 || goodsStyle !== 4, 'main-center' : goodsStyle === 3 || goodsStyle === 4}"
  102. :style="{position: showGoodsPrice === false ? 'relative' : ''}">
  103. <text v-if="showGoodsPrice" class="app-price">{{item.price_content}}</text>
  104. <view v-if="showBuyBtn" :class="{'app-button-no-price' : showGoodsPrice === false}">
  105. <button v-if="buyBtn === 'text' && goodsStyle !== 3 && goodsStyle !== 4"
  106. @click.stop="buyProduct(item)"
  107. :class="{
  108. 'app-button-filling': buyBtnStyle === 1,
  109. 'app-button-line' : buyBtnStyle === 2 ,
  110. 'app-button-fillet' : buyBtnStyle === 3,
  111. 'app-button-rounded-lines': buyBtnStyle === 4,
  112. }"
  113. >{{buyBtnText}}</button>
  114. <icon class="app-icon-button app-shopping-cart"
  115. @click.stop="buyProduct(item)"
  116. v-else-if="buyBtn === 'cart' && goodsStyle !== 3 && goodsStyle !== 4"></icon>
  117. <icon class="app-icon-button app-add-to"
  118. @click.stop="buyProduct(item)"
  119. v-else-if="buyBtn === 'add' && goodsStyle !== 3 && goodsStyle !== 4"></icon>
  120. </view>
  121. </view>
  122. </app-form-id>
  123. </view>
  124. </view>
  125. <!-- 一行两个 -->
  126. <view class="app-one-line-two dir-left-wrap" v-if="listStyle === 2">
  127. <view class="app-item"
  128. :class="{'app-border': goodsStyle === 2 || goodsStyle === 4}"
  129. v-for="(item, index) in list"
  130. :key="index"
  131. >
  132. <app-form-id @click="jump(item)">
  133. <image
  134. class="app-icon"
  135. :src="goodsTagPicUrl"
  136. v-if="showGoodsTag"
  137. ></image>
  138. <image class="app-image"
  139. :mode="fill === 1 ? 'scaleToFill' : fill === 2 ? 'aspectFit': ''"
  140. :src="item.cover_pic"
  141. ></image>
  142. <text v-if="showGoodsName"
  143. class="app-name"
  144. :class="{'app-name-goods-style': goodsStyle === 3 || goodsStyle === 4}"
  145. >{{item.name}}</text>
  146. <view
  147. class="app-price-buttons dir-left-nowrap cross-center"
  148. :class="{'main-between': showGoodsPrice, 'main-right': !showGoodsPrice, 'main-center': goodsStyle === 3 || goodsStyle === 4}"
  149. >
  150. <text v-if="showGoodsPrice"
  151. class="app-price"
  152. >{{item.price_content}}</text>
  153. <template v-if="showBuyBtn">
  154. <button
  155. v-if="buyBtn === 'text' && goodsStyle !== 3 && goodsStyle !== 4"
  156. @click.stop="buyProduct(item)"
  157. :class="{
  158. 'app-button-filling': buyBtnStyle === 1,
  159. 'app-button-line' : buyBtnStyle === 2 ,
  160. 'app-button-fillet' : buyBtnStyle === 3,
  161. 'app-button-rounded-lines': buyBtnStyle === 4,
  162. }"
  163. >{{buyBtnText}}</button>
  164. <icon class="app-icon-button app-shopping-cart"
  165. @click.stop="buyProduct(item)"
  166. v-else-if="buyBtn === 'cart' && goodsStyle !== 3 && goodsStyle !== 4"
  167. ></icon>
  168. <icon class="app-icon-button app-add-to"
  169. @click.stop="buyProduct(item)"
  170. v-else-if="buyBtn === 'add' && goodsStyle !== 3 && goodsStyle !== 4"
  171. ></icon>
  172. </template>
  173. </view>
  174. </app-form-id>
  175. </view>
  176. </view>
  177. <!-- 一行三个 -->
  178. <view class="app-one-line-three dir-left-wrap" v-if="listStyle === 3">
  179. <view class="app-item"
  180. v-for="(item, index) in list"
  181. :key="index"
  182. :class="{'app-border': goodsStyle === 2 || goodsStyle === 4}"
  183. >
  184. <app-form-id @click="jump(item)">
  185. <image
  186. class="app-icon"
  187. :src="goodsTagPicUrl"
  188. v-if="showGoodsTag"
  189. ></image>
  190. <image class="app-image"
  191. :mode="fill === 1 ? 'scaleToFill' : fill === 2 ? 'aspectFit': ''"
  192. :src="item.cover_pic"
  193. ></image>
  194. <text class="app-name"
  195. :class="{'app-name-goods-style': goodsStyle === 3 || goodsStyle === 4}"
  196. v-if="showGoodsName">{{item.name}}</text>
  197. <view class="app-price-buttons dir-left-nowrap cross-center"
  198. :class="{'main-between': goodsStyle !== 3 && goodsStyle !== 4, 'main-center': goodsStyle === 3 || goodsStyle === 4}"
  199. >
  200. <text class="app-price"
  201. v-if="showGoodsPrice"
  202. >{{item.price_content}}</text>
  203. <icon class="app-icon-button app-shopping-cart"
  204. @click.stop="buyProduct(item)"
  205. v-if="buyBtn === 'cart' && goodsStyle !== 3 && goodsStyle !== 4"
  206. ></icon>
  207. <icon class="app-icon-button app-add-to"
  208. @click.stop="buyProduct(item)"
  209. v-else-if="buyBtn === 'add' && goodsStyle !== 3 && goodsStyle !== 4"
  210. ></icon>
  211. </view>
  212. </app-form-id>
  213. </view>
  214. </view>
  215. </view>
  216. <view class="app-content" v-if="showCat">
  217. <!-- 列表模式 -->
  218. <view class="app-list-mode" v-if="listStyle === -1">
  219. <view class="app-page" v-for="(page, number) in catList" :key="number" v-if="activeCurrent === number">
  220. <view :class="{'app-border': goodsStyle === 2}" :key="index" v-for="(item, index) in page.goodsList">
  221. <app-form-id @click="jump(item)">
  222. <view class="app-item dir-left-nowrap">
  223. <image class="app-icon" :src="goodsTagPicUrl" v-if="showGoodsTag"></image>
  224. <image class="app-image" :mode="fill === 1 ? 'scaleToFill' : fill === 2 ? 'aspectFit': ''" :src="item.cover_pic"></image>
  225. <view class="app-item-content dir-top-nowrap" :class="{'main-right': showGoodsName === false}">
  226. <text class="app-name" v-if="showGoodsName">{{item.name}}</text>
  227. <view class="app-price-button dir-left-nowrap" :class="{'main-between': showGoodsPrice, 'main-right': !showGoodsPrice}">
  228. <text v-if="showGoodsPrice" class="app-text">{{item.price_content}}</text>
  229. <template v-if="showBuyBtn">
  230. <button v-if="buyBtn === 'text'"
  231. @click.stop="buyProduct(item)"
  232. :class="{
  233. 'app-button-filling': buyBtnStyle === 1,
  234. 'app-button-line' : buyBtnStyle === 2 ,
  235. 'app-button-fillet' : buyBtnStyle === 3,
  236. 'app-button-rounded-lines': buyBtnStyle === 4,
  237. }"
  238. >{{buyBtnText}}</button>
  239. <icon class="app-icon-button app-shopping-cart"
  240. @click.stop="buyProduct(item)"
  241. v-else-if="buyBtn === 'cart'"></icon>
  242. <icon class="app-icon-button app-add-to"
  243. @click.stop="buyProduct(item)"
  244. v-else-if="buyBtn === 'add'"></icon>
  245. </template>
  246. </view>
  247. </view>
  248. </view>
  249. </app-form-id>
  250. </view>
  251. </view>
  252. </view>
  253. <!-- 左右滑动 -->
  254. <view class="app-swipe-left-right" v-if="listStyle === 0">
  255. <view class="app-page" v-for="(page, number) in catList" :key="number" v-if="activeCurrent === number">
  256. <scroll-view class="scroll-view" scroll-with-animation scroll-x>
  257. <view class="app-item" :class="{'app-border': goodsStyle === 2 || goodsStyle === 4}" v-for="(item, index) in page.goodsList" :key="index">
  258. <app-form-id @click="jump(item)">
  259. <image class="app-icon" :src="goodsTagPicUrl" v-if="showGoodsTag"></image>
  260. <image class="app-image" :mode="fill === 1 ? 'scaleToFill' : fill === 2 ? 'aspectFit': ''" :src="item.cover_pic"></image>
  261. <view class="app-price-button-name dir-top-nowrap">
  262. <text v-if="showGoodsName" class="app-name" :class="{'app-name-goods-style': goodsStyle === 3 || goodsStyle === 4}">{{item.name}}</text>
  263. <view class="app-price-button dir-left-nowrap cross-bottom"
  264. :class="{
  265. 'app-price-goods-style': goodsStyle === 3 || goodsStyle === 4,
  266. 'main-right': showGoodsPrice === false
  267. }">
  268. <text v-if="showGoodsPrice" class="app-price" :class="{'app-price-goods-style': goodsStyle === 3 || goodsStyle === 4}">{{item.price_content}}</text>
  269. <template v-if="goodsStyle !== 3 && goodsStyle !== 4">
  270. <icon class="app-icon-button app-shopping-cart"
  271. @click.stop="buyProduct(item)"
  272. v-if="buyBtn === 'cart'"></icon>
  273. <icon class="app-icon-button app-add-to"
  274. @click.stop="buyProduct(item)"
  275. v-else-if="buyBtn === 'add'"></icon>
  276. </template>
  277. </view>
  278. </view>
  279. </app-form-id>
  280. </view>
  281. </scroll-view>
  282. </view>
  283. </view>
  284. <!-- 一行一个 -->
  285. <view class="app-one-per-line" v-if="listStyle === 1">
  286. <view class="app-page" v-for="(page, number) in catList" :key="number" v-if="activeCurrent === number">
  287. <view class="app-item" :class="{'app-border': goodsStyle === 2 || goodsStyle === 4, 'app-square': goodsCoverProportion === '1-1',
  288. 'app-rectangle': goodsCoverProportion === '3-2'
  289. }" v-for="(item, index) in page.goodsList" :key="index">
  290. <app-form-id @click="jump(item)">
  291. <image class="app-icon" :src="goodsTagPicUrl" v-if="showGoodsTag"></image>
  292. <image class="app-image"
  293. :mode="fill === 1 && goodsCoverProportion === '3-2'? 'center' :goodsCoverProportion === '3-2' && fill === 2 ? 'aspectFit': fill === 1 && goodsCoverProportion === '1-1' ? 'scaleToFill' : goodsCoverProportion === '1-1' && fill === 2 ? 'scaleToFill' : ''"
  294. :class="{
  295. 'app-square-image': goodsCoverProportion === '1-1',
  296. 'app-rectangle-image': goodsCoverProportion === '3-2',
  297. }"
  298. :src="item.cover_pic"
  299. ></image>
  300. <text class="app-text" :style="{textAlign: goodsStyle === 3 ? 'center' : ''}" v-if="showGoodsName">{{item.name}}</text>
  301. <view v-if="showBuyBtn && showGoodsPrice"
  302. class="app-button-price dir-left-nowrap cross-center"
  303. :class="{'main-between': goodsStyle !== 3 || goodsStyle !== 4, 'main-center' : goodsStyle === 3 || goodsStyle === 4}"
  304. :style="{position: showGoodsPrice === false ? 'relative' : ''}">
  305. <text v-if="showGoodsPrice" class="app-price">{{item.price_content}}</text>
  306. <view v-if="showBuyBtn" :class="{'app-button-no-price' : showGoodsPrice === false}">
  307. <button v-if="buyBtn === 'text' && goodsStyle !== 3 && goodsStyle !== 4"
  308. @click.stop="buyProduct(item)"
  309. :class="{
  310. 'app-button-filling': buyBtnStyle === 1,
  311. 'app-button-line' : buyBtnStyle === 2 ,
  312. 'app-button-fillet' : buyBtnStyle === 3,
  313. 'app-button-rounded-lines': buyBtnStyle === 4,
  314. }"
  315. >{{buyBtnText}}</button>
  316. <icon class="app-icon-button app-shopping-cart"
  317. @click.stop="buyProduct(item)"
  318. v-else-if="buyBtn === 'cart' && goodsStyle !== 3 && goodsStyle !== 4"></icon>
  319. <icon class="app-icon-button app-add-to"
  320. @click.stop="buyProduct(item)"
  321. v-else-if="buyBtn === 'add' && goodsStyle !== 3 && goodsStyle !== 4"></icon>
  322. </view>
  323. </view>
  324. </app-form-id>
  325. </view>
  326. </view>
  327. </view>
  328. <!-- 一行两个 -->
  329. <template v-if="listStyle === 2">
  330. <view class="app-page app-one-line-two dir-left-wrap" v-for="(page, number) in catList" :key="number" v-if="activeCurrent === number">
  331. <view class="app-item"
  332. :class="{'app-border': goodsStyle === 2 || goodsStyle === 4}"
  333. v-for="(item, index) in page.goodsList"
  334. :key="index"
  335. >
  336. <app-form-id @click="jump(item)">
  337. <image
  338. class="app-icon"
  339. :src="goodsTagPicUrl"
  340. v-if="showGoodsTag"
  341. ></image>
  342. <image class="app-image"
  343. :mode="fill === 1 ? 'scaleToFill' : fill === 2 ? 'aspectFit': ''"
  344. :src="item.cover_pic"
  345. ></image>
  346. <text v-if="showGoodsName"
  347. class="app-name"
  348. :class="{'app-name-goods-style': goodsStyle === 3 || goodsStyle === 4}"
  349. >{{item.name}}</text>
  350. <view
  351. class="app-price-buttons dir-left-nowrap cross-center"
  352. :class="{'main-between': showGoodsPrice, 'main-right': !showGoodsPrice, 'main-center': goodsStyle === 3 || goodsStyle === 4}"
  353. >
  354. <text v-if="showGoodsPrice"
  355. class="app-price"
  356. >{{item.price_content}}</text>
  357. <template v-if="showBuyBtn">
  358. <button
  359. v-if="buyBtn === 'text' && goodsStyle !== 3 && goodsStyle !== 4"
  360. @click.stop="buyProduct(item)"
  361. :class="{
  362. 'app-button-filling': buyBtnStyle === 1,
  363. 'app-button-line' : buyBtnStyle === 2 ,
  364. 'app-button-fillet' : buyBtnStyle === 3,
  365. 'app-button-rounded-lines': buyBtnStyle === 4,
  366. }"
  367. >{{buyBtnText}}</button>
  368. <icon class="app-icon-button app-shopping-cart"
  369. @click.stop="buyProduct(item)"
  370. v-else-if="buyBtn === 'cart' && goodsStyle !== 3 && goodsStyle !== 4"
  371. ></icon>
  372. <icon class="app-icon-button app-add-to"
  373. @click.stop="buyProduct(item)"
  374. v-else-if="buyBtn === 'add' && goodsStyle !== 3 && goodsStyle !== 4"
  375. ></icon>
  376. </template>
  377. </view>
  378. </app-form-id>
  379. </view>
  380. </view>
  381. </template>
  382. <!-- 一行三个 -->
  383. <template v-if="listStyle === 3">
  384. <view class="app-page app-one-line-three dir-left-wrap" v-for="(page, number) in catList" :key="number" v-if="activeCurrent === number">
  385. <view class="app-item"
  386. :class="{'app-border': goodsStyle === 2 || goodsStyle === 4}"
  387. v-for="(item, index) in page.goodsList"
  388. :key="index"
  389. >
  390. <app-form-id @click="jump(item)">
  391. <image
  392. class="app-icon"
  393. :src="goodsTagPicUrl"
  394. v-if="showGoodsTag"
  395. ></image>
  396. <image class="app-image"
  397. :mode="fill === 1 ? 'scaleToFill' : fill === 2 ? 'aspectFit': ''"
  398. :src="item.cover_pic"
  399. ></image>
  400. <text v-if="showGoodsName"
  401. class="app-name"
  402. :class="{'app-name-goods-style': goodsStyle === 3 || goodsStyle === 4}"
  403. >{{item.name}}</text>
  404. <view
  405. class="app-price-buttons dir-left-nowrap cross-center"
  406. :class="{'main-between': showGoodsPrice, 'main-right': !showGoodsPrice, 'main-center': goodsStyle === 3 || goodsStyle === 4}"
  407. >
  408. <text v-if="showGoodsPrice"
  409. class="app-price"
  410. >{{item.price_content}}</text>
  411. <template v-if="showBuyBtn">
  412. <button
  413. @click.stop="buyProduct(item)"
  414. v-if="buyBtn === 'text' && goodsStyle !== 3 && goodsStyle !== 4"
  415. :class="{
  416. 'app-button-filling': buyBtnStyle === 1,
  417. 'app-button-line' : buyBtnStyle === 2 ,
  418. 'app-button-fillet' : buyBtnStyle === 3,
  419. 'app-button-rounded-lines': buyBtnStyle === 4,
  420. }"
  421. >{{buyBtnText}}</button>
  422. <icon class="app-icon-button app-shopping-cart"
  423. @click.stop=""
  424. v-else-if="buyBtn === 'cart' && goodsStyle !== 3 && goodsStyle !== 4"
  425. ></icon>
  426. <icon class="app-icon-button app-add-to"
  427. @click.stop="buyProduct(item)"
  428. v-else-if="buyBtn === 'add' && goodsStyle !== 3 && goodsStyle !== 4"
  429. ></icon>
  430. </template>
  431. </view>
  432. </app-form-id>
  433. </view>
  434. </view>
  435. </template>
  436. </view><view>
  437. <app-attr
  438. :goods="goods"
  439. :attrGroupList="goods.attr_groups"
  440. :show="show"
  441. :selectAttr="selectAttr"
  442. @attr="attr"
  443. ></app-attr>
  444. </view>
  445. </view>
  446. </template>
  447. <script>
  448. import {mapGetters} from 'vuex';
  449. import appAttr from '../../../components/page-component/app-attr/app-attr.vue';
  450. export default {
  451. name: 'app-recommended-product',
  452. props: {
  453. showCat: {
  454. type: Boolean,
  455. default: function() {
  456. return true;
  457. }
  458. },
  459. showBuyBtn: {
  460. type: Boolean,
  461. default: function() {
  462. return true;
  463. }
  464. },
  465. showGoodsName: {
  466. type: Boolean,
  467. default: function() {
  468. return true;
  469. }
  470. },
  471. showGoodsPrice: {
  472. type: Boolean,
  473. default: function() {
  474. return true;
  475. }
  476. },
  477. showGoodsTag: {
  478. type: Boolean,
  479. default: function() {
  480. return true;
  481. }
  482. },
  483. goodsTagPicUrl: {
  484. type: String,
  485. default: function() {
  486. return 'https://www.bangdian.net/plugins/diy/assets/images/goods-tag-rx.png';
  487. }
  488. },
  489. goodsCoverProportion: {
  490. type: String,
  491. default: function() {
  492. return '1-1';
  493. }
  494. },
  495. goodsStyle: {
  496. type: Number,
  497. default: function() {
  498. return 1;
  499. }
  500. },
  501. listStyle: {
  502. type: Number,
  503. default: function() {
  504. return 2;
  505. }
  506. },
  507. list: {
  508. type: Array,
  509. default: function () {
  510. return [
  511. ];
  512. }
  513. },
  514. fill: {
  515. type: Number,
  516. default: function() {
  517. return 2;
  518. }
  519. },
  520. customizeGoodsTag: {
  521. type: Boolean,
  522. default: function() {
  523. return false;
  524. }
  525. },
  526. catStyle: {
  527. type: Number,
  528. default:function() {
  529. return 2;
  530. }
  531. },
  532. buyBtnText: {
  533. type: String,
  534. default: function() {
  535. return '购买放电';
  536. }
  537. },
  538. buyBtnStyle: {
  539. type: Number,
  540. default: function() {
  541. return 1;
  542. }
  543. },
  544. buyBtn: {
  545. type: String,
  546. default: function() {
  547. return 'cart';
  548. }
  549. },
  550. catList: {
  551. type: Array,
  552. default: function() {
  553. return [];
  554. }
  555. }
  556. },
  557. data() {
  558. return {
  559. activeCurrent: 0,
  560. goods: {},
  561. }
  562. },
  563. computed: {
  564. ...mapGetters('mallConfig',{
  565. getVideo: 'getVideo'
  566. }),
  567. },
  568. methods: {
  569. change(index) {
  570. this.activeCurrent = index;
  571. },
  572. buyProduct(data) {
  573. if (data.mch_id === 0) {
  574. this.$request({
  575. url: this.$api.goods.detail,
  576. data: {
  577. id: data.id,
  578. }
  579. }).then(response => {
  580. if (response.code === 0) {
  581. this.goods = response.data.goods;
  582. this.show = Math.random();
  583. }
  584. })
  585. } else {
  586. this.$request({
  587. url: this.$api.mch.goods_detail,
  588. data: {
  589. mch_id: data.mch_id,
  590. id: data.id,
  591. }
  592. }).then(response => {
  593. if (response.code === 0) {
  594. this.goods = response.data.goods;
  595. this.show = Math.random();
  596. }
  597. })
  598. }
  599. },
  600. jump(data) {
  601. // #ifndef MP-BAIDU
  602. if (data.video_url && this.getVideo == 1) {
  603. uni.navigateTo({
  604. url: `/pages/goods/video?goods_id=${data.id}`
  605. });
  606. } else {
  607. uni.navigateTo({
  608. url: data.page_url
  609. });
  610. }
  611. // #endif
  612. // #ifdef MP-BAIDU
  613. uni.navigateTo({
  614. url: data.page_url
  615. });
  616. // #endif
  617. }
  618. },
  619. components: {
  620. 'app-attr': appAttr,
  621. }
  622. }
  623. </script>
  624. <style scoped lang="scss">
  625. .app-icon {
  626. width: #{55rpx};
  627. height: #{55rpx};
  628. position: absolute;
  629. top: 0;
  630. left: 0;
  631. }
  632. /* #ifdef MP-ALIPAY*/
  633. button {
  634. padding: 0 #{20rpx};
  635. }
  636. /* #endif */
  637. /* #ifdef MP-BAIDU*/
  638. button:after {
  639. display: none;
  640. }
  641. /* #endif */
  642. .app-recommended-product {
  643. width: #{750rpx};
  644. .app-display-classification {
  645. width: #{750rpx};
  646. height: #{99rpx};
  647. border-bottom: #{1rpx} solid #e2e2e2;
  648. .app-scroll-view {
  649. white-space: nowrap;
  650. width: #{750-5-5rpx};
  651. margin: 0 #{5rpx};
  652. height: #{99-1rpx};
  653. /* #ifdef MP-ALIPAY */
  654. .app-nav-item {
  655. display: inline-block;
  656. height: #{97rpx};
  657. min-width: #{60rpx};
  658. line-height: #{97rpx};
  659. font-size: #{26rpx};
  660. color: #666666;
  661. margin: 0 #{44rpx};
  662. border-bottom: #{1rpx} solid transparent;
  663. }
  664. /* #endif */
  665. /* #ifndef MP-ALIPAY */
  666. .app-nav-item {
  667. display: inline-block;
  668. height: #{97rpx};
  669. line-height: #{97rpx};
  670. font-size: #{26rpx};
  671. color: #666666;
  672. margin: 0 #{44rpx};
  673. border-bottom: #{1rpx} solid transparent;
  674. }
  675. /* #endif */
  676. .app-active-current {
  677. border-bottom-color: #ff5c5c;
  678. color: #ff5c5c;
  679. }
  680. /* #ifdef MP-ALIPAY */
  681. .app-current-round {
  682. height: #{56rpx};
  683. padding-left: #{24rpx};
  684. min-width: #{100rpx};
  685. padding-right: #{24rpx};
  686. border-radius: #{30rpx};
  687. line-height: #{56rpx};
  688. margin: #{21.5rpx} #{24rpx};
  689. }
  690. /* #endif */
  691. /* #ifndef MP-ALIPAY */
  692. .app-current-round {
  693. height: #{56rpx};
  694. padding-left: #{24rpx};
  695. padding-right: #{24rpx};
  696. border-radius: #{30rpx};
  697. line-height: #{56rpx};
  698. margin: #{21.5rpx} #{24rpx};
  699. }
  700. /* #endif */
  701. .app-active-current-round {
  702. background-color: #ff5c5c;
  703. color: white;
  704. }
  705. }
  706. }
  707. .app-icon-button {
  708. background-repeat: no-repeat;
  709. background-size: 100% 100%;
  710. width: #{50rpx};
  711. height: #{50rpx};
  712. }
  713. .app-shopping-cart {
  714. background-image: url("../../../static/image/icon/shopping-cart.png");
  715. }
  716. .app-add-to {
  717. background-image: url("../../../static/image/icon/add-to.png");
  718. }
  719. .app-border {
  720. border-color: #e2e2e2 !important;
  721. }
  722. /*列表模式*/
  723. .app-list-mode {
  724. .app-item {
  725. margin: #{32rpx} #{24rpx};
  726. width: #{750-24-24rpx};
  727. height: #{200rpx};
  728. border: #{1rpx} solid transparent;
  729. position: relative;
  730. overflow: hidden;
  731. background: #FFFFFF;
  732. .app-image {
  733. width: #{200rpx};
  734. height: #{198rpx};
  735. }
  736. .app-item-content {
  737. height: #{200rpx};
  738. width: #{500rpx};
  739. padding: #{24rpx} #{24rpx} #{20rpx} #{32rpx};
  740. .app-name {
  741. display: -webkit-box;
  742. -webkit-box-orient: vertical;
  743. -webkit-line-clamp: 2;
  744. overflow: hidden;
  745. height: #{66rpx};
  746. font-size: #{26rpx};
  747. }
  748. .app-price-button button {
  749. display: inline-block;
  750. margin: 0;
  751. height: #{48rpx};
  752. font-size: #{28rpx};
  753. line-height: #{48rpx};
  754. border-radius: 0;
  755. }
  756. .app-button-filling {
  757. color: #ffffff;
  758. background-color: #ff5c5c;
  759. }
  760. .app-button-fillet {
  761. color: #ffffff;
  762. background-color: #ff5c5c;
  763. border-radius: #{20rpx} !important;
  764. }
  765. .app-button-line {
  766. border: #{1rpx} solid #ff5c5c;
  767. color: #ff5c5c;
  768. }
  769. .app-button-rounded-lines {
  770. border: #{1rpx} solid #ff5c5c;
  771. color: #ff5c5c;
  772. border-radius: #{20rpx} !important;
  773. }
  774. .app-text {
  775. color: #ff4544;
  776. font-size: #{28rpx};
  777. }
  778. .app-price-button {
  779. margin-top: #{28rpx};
  780. }
  781. .app-price-button button:after {
  782. display: none;
  783. }
  784. }
  785. }
  786. }
  787. /*左右滑动*/
  788. .app-swipe-left-right {
  789. width: #{750rpx};
  790. .scroll-view {
  791. white-space: nowrap;
  792. width: #{750rpx};
  793. margin: 0 #{8rpx};
  794. padding-top: #{24rpx};
  795. padding-bottom: #{32rpx};
  796. .app-item {
  797. display: inline-block;
  798. width: #{200rpx};
  799. overflow: hidden;
  800. margin: 0 #{16rpx};
  801. position: relative;
  802. border: #{1rpx} solid transparent;
  803. background: #FFFFFF;
  804. .app-image {
  805. width: #{200rpx};
  806. height: #{200rpx};
  807. }
  808. .app-name {
  809. width: #{200-12-12rpx};
  810. height: #{48rpx};
  811. font-size: #{24rpx};
  812. line-height: #{24rpx};
  813. color: #353535;
  814. display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 2;
  815. overflow: hidden;
  816. }
  817. .app-name-goods-style {
  818. text-align: center;
  819. }
  820. .app-price-button-name {
  821. width: #{200-12-12rpx};
  822. margin: 0 #{12rpx};
  823. .app-price-goods-style {
  824. width: #{200-12-12rpx} !important;
  825. }
  826. .app-icon-button {
  827. margin-top: #{16rpx};
  828. margin-left: #{16rpx};
  829. }
  830. .app-price {
  831. width: #{110rpx};
  832. height: #{28rpx};
  833. font-size: #{28rpx};
  834. line-height: #{28rpx};
  835. color: #ff4544;
  836. text-align: center;
  837. overflow: hidden;
  838. text-overflow:ellipsis;
  839. white-space: nowrap;
  840. margin-bottom: #{12rpx};
  841. }
  842. }
  843. }
  844. }
  845. }
  846. /*一行一个*/
  847. .app-one-per-line {
  848. width: #{750rpx};
  849. padding: #{26rpx} #{24rpx};
  850. .app-square {
  851. }
  852. .app-rectangle {
  853. }
  854. .app-item {
  855. width: #{750-24-24rpx};
  856. border: #{1rpx} solid transparent;
  857. border-bottom-left-radius: #{20rpx};
  858. border-bottom-right-radius: #{20rpx};
  859. margin-bottom: #{12rpx};
  860. position: relative;
  861. padding-bottom: #{24rpx};
  862. background: #FFFFFF;
  863. .app-image {
  864. width: #{702rpx};
  865. }
  866. .app-square-image {
  867. height: #{702rpx};
  868. }
  869. .app-rectangle-image {
  870. height: #{702-234rpx};
  871. }
  872. .app-icon {
  873. width: #{60rpx};
  874. height: #{60rpx};
  875. position: absolute;
  876. top: 0;
  877. left: 0;
  878. }
  879. .app-text {
  880. width: #{702rpx};
  881. padding: 0 #{24rpx};
  882. margin-top: #{28rpx};
  883. font-size: #{26rpx};
  884. color: #353535;
  885. display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 1;
  886. overflow: hidden;
  887. }
  888. .app-button-price {
  889. width: #{702-24-24rpx};
  890. margin: #{32rpx} #{24rpx};
  891. height: #{50rpx};
  892. .app-price {
  893. font-size: #{28rpx};
  894. color: #ff4544;
  895. }
  896. button {
  897. display: inline-block;
  898. margin: 0;
  899. height: #{48rpx};
  900. font-size: #{28rpx};
  901. line-height: #{48rpx};
  902. border-radius: 0;
  903. }
  904. .app-button-no-price {
  905. position: absolute;
  906. right: 0;
  907. }
  908. .app-button-filling {
  909. color: #ffffff;
  910. background-color: #ff5c5c;
  911. }
  912. .app-button-fillet {
  913. color: #ffffff;
  914. background-color: #ff5c5c;
  915. border-radius: #{20rpx} !important;
  916. }
  917. .app-button-line {
  918. border: #{1rpx} solid #ff5c5c;
  919. color: #ff5c5c;
  920. }
  921. .app-button-rounded-lines {
  922. border: #{1rpx} solid #ff5c5c;
  923. color: #ff5c5c;
  924. border-radius: #{20rpx} !important;
  925. }
  926. }
  927. }
  928. }
  929. /* 一行两个 */
  930. .app-one-line-two {
  931. width: #{750rpx};
  932. padding: #{2rpx} #{19rpx} #{0} #{19rpx};
  933. .app-item {
  934. width: #{346rpx};
  935. margin: #{24rpx} #{5rpx} #{0rpx} #{5rpx};
  936. border: #{1rpx} solid transparent;
  937. position: relative;
  938. background: #FFFFFF;
  939. .app-icon {
  940. width: #{55rpx};
  941. height: #{55rpx};
  942. position: absolute;
  943. top: 0;
  944. left: 0;
  945. }
  946. .app-image {
  947. width: #{343rpx};
  948. height: #{343rpx};
  949. }
  950. .app-name {
  951. width: #{346-24-24rpx};
  952. margin: #{24rpx} #{24rpx} 0 #{24rpx};
  953. display: -webkit-box;
  954. -webkit-box-orient: vertical;
  955. -webkit-line-clamp: 2;
  956. overflow: hidden;
  957. color: #353535;
  958. font-size: #{26rpx};
  959. /* #ifndef MP-ALIPAY*/
  960. height: #{64rpx};
  961. /* #endif */
  962. /* #ifdef MP-ALIPAY */
  963. height: #{55rpx};
  964. /* #endif */
  965. }
  966. .app-name-goods-style {
  967. text-align: center;
  968. }
  969. .app-price-buttons {
  970. margin: #{32rpx} #{24rpx} #{48rpx} #{24rpx};
  971. button {
  972. display: inline-block;
  973. margin: 0;
  974. height: #{48rpx};
  975. font-size: #{25rpx};
  976. line-height: #{48rpx};
  977. border-radius: 0;
  978. padding: 0 #{11rpx};
  979. }
  980. .app-price {
  981. color: #ff4544;
  982. font-size: #{28rpx};
  983. }
  984. .app-button-filling {
  985. color: #ffffff;
  986. background-color: #ff5c5c;
  987. }
  988. .app-button-fillet {
  989. color: #ffffff;
  990. background-color: #ff5c5c;
  991. border-radius: #{20rpx} !important;
  992. }
  993. .app-button-line {
  994. border: #{1rpx} solid #ff5c5c;
  995. color: #ff5c5c;
  996. }
  997. .app-button-rounded-lines {
  998. border: #{1rpx} solid #ff5c5c;
  999. color: #ff5c5c;
  1000. border-radius: #{20rpx} !important;
  1001. }
  1002. }
  1003. }
  1004. }
  1005. /* 一行三个 */
  1006. .app-one-line-three {
  1007. width: #{750rpx};
  1008. padding: #{8rpx} #{16.5rpx};
  1009. .app-item {
  1010. background: #FFFFFF;
  1011. width: #{224rpx};
  1012. margin: #{16rpx} #{7.5rpx} #{16rpx} #{7.5rpx};
  1013. position: relative;
  1014. border: #{1rpx} solid transparent;
  1015. padding-bottom: #{8rpx};
  1016. .app-image {
  1017. width: #{221rpx};
  1018. height: #{221rpx};
  1019. }
  1020. .app-name {
  1021. font-size: #{28rpx};
  1022. color: #353535;
  1023. display: -webkit-box;
  1024. -webkit-box-orient: vertical;
  1025. -webkit-line-clamp: 2;
  1026. overflow: hidden;
  1027. width: #{224-12-12rpx};
  1028. margin: #{16rpx} #{12rpx} #{0} #{12rpx};
  1029. /* #ifndef MP-ALIPAY */
  1030. height: #{70rpx};
  1031. /* #endif */
  1032. /* #ifdef MP-ALIPAY */
  1033. height: #{60rpx};
  1034. /* #endif */
  1035. }
  1036. .app-name-goods-style {
  1037. text-align: center;
  1038. }
  1039. .app-price-buttons {
  1040. margin: #{16rpx} #{12rpx} #{0} #{12rpx};
  1041. .app-price {
  1042. width: #{135rpx};
  1043. font-size: #{28rpx};
  1044. height: #{28rpx};
  1045. line-height: #{28rpx};
  1046. display: -webkit-box;
  1047. -webkit-box-orient: vertical;
  1048. -webkit-line-clamp: 1;
  1049. overflow: hidden;
  1050. color: #ff4544;
  1051. }
  1052. }
  1053. }
  1054. }
  1055. }
  1056. .app-page {
  1057. width: #{750rpx};
  1058. }
  1059. </style>