耀实惠小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

362 lines
8.0 KiB

  1. <!-- <template>
  2. <view class="pages">
  3. <u-sticky>
  4. <view>
  5. <view class="search"><u-search v-model="keyword" placeholder="请输入要搜索的商品" height="70" :show-action="false" @search="search" /></view>
  6. <u-tabs :list="nav_list" :is-scroll="false" :current="status" @change="getGoodsListInfo" bar-width="80" active-color="#01AEEA" font-size="34"></u-tabs>
  7. </view>
  8. </u-sticky>
  9. <view class="top_bg_text" :style="'background-image: url('+pageImage+')'">
  10. </view>
  11. <view class="over_y">
  12. <view class="item_goods" v-for="(item,index) in list" :key="index">
  13. <goods-item :goods="item" thereTo='ZeroMoneyBuy'></goods-item>
  14. </view>
  15. </view>
  16. </view>
  17. </template> -->
  18. <template>
  19. <view class="pages">
  20. <u-sticky>
  21. <view>
  22. <view class="search"><u-search v-model="keyword" placeholder="请输入要搜索的商品" height="70" :show-action="false" @search="search" /></view>
  23. <u-tabs :list="nav_list" :is-scroll="true" :current="status" @change="getGoodsListInfo" bar-width="80" active-color="#01AEEA" font-size="34"></u-tabs>
  24. </view>
  25. </u-sticky>
  26. <view class="top_bg_text" :style="'background-image: url('+pageImage+')'">
  27. <text class="title_max">{{title}}</text>
  28. <text class="title_min">{{title_alt}}</text>
  29. </view>
  30. <view class="over_y">
  31. <view class="item_goods" v-for="(item,index) in list" :key="index">
  32. <goods-item :goods="item" thereTo='ZeroMoneyBuy'></goods-item>
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import config from "@/utils/js/config.js"
  39. export default {
  40. data() {
  41. return {
  42. status: '0',
  43. butClass:'1',
  44. nav_list: [
  45. {
  46. name: "全部"
  47. },
  48. ],
  49. payNum:0, // 0 非处方 1处方
  50. http_img: config.img_url,
  51. pageImage: "",
  52. title: "",
  53. title_alt: "",
  54. list: [],
  55. pageNo: 1,
  56. pageSize: 10,
  57. total: null,
  58. isLock: true,
  59. id: '',
  60. keyword: ''
  61. }
  62. },
  63. onPullDownRefresh() {
  64. this.pageNo= 1;
  65. this.total = null;
  66. this.list = [];
  67. this.getGoodsList();
  68. },
  69. onReachBottom() {
  70. if(this.isLock) {
  71. if(this.total !== null && this.pageNo * this.pageSize >= this.total){
  72. this.isLock = false;
  73. this.$Toast('没有更多数据了哦!');
  74. setTimeout(()=>{
  75. this.isLock = true;
  76. },3000)
  77. return
  78. }
  79. this.pageNo+=1;
  80. this.getGoodsList();
  81. }
  82. },
  83. onLoad(options) {
  84. this.id = options.id;
  85. this.pageImage = options.pageImage
  86. this.getGoodsList();
  87. this.getButClass();
  88. },
  89. methods: {
  90. getButClass(){
  91. this.$api('getButClassList', {}).then(res => {
  92. this.nav_list = this.nav_list.concat(res.result)
  93. }).catch(err => {
  94. this.$Toast(err.message)
  95. })
  96. },
  97. search () {
  98. this.pageNo = 1
  99. this.getGoodsList()
  100. },
  101. getGoodsListInfo(e){
  102. this.status = e;
  103. this.butClass = this.nav_list[e].id;
  104. this.list = [];
  105. this.pageNo = 1;
  106. this.total = null;
  107. this.isLock = true;
  108. this.payNum = e;
  109. this.getGoodsList()
  110. console.log("获取新数据",e)
  111. },
  112. getGoodsList() {
  113. uni.showLoading();
  114. const params = {
  115. pageNo: this.pageNo,
  116. pageSize: this.pageSize,
  117. bottonId:this.id,
  118. title: this.keyword,
  119. payNum:this.payNum,
  120. butClass:this.butClass
  121. }
  122. this.$api('getGoodsList',params).then(res => {
  123. let { code, result, message} = res;
  124. uni.hideLoading();
  125. if(code == 200){
  126. if(this.total == null) {
  127. this.total = result.total;
  128. }
  129. result.records.forEach(item => {
  130. if(item.pic!==null){
  131. const picArray=item.pic.split(',')
  132. item.pic= picArray[0]
  133. }else{
  134. item.pic= []
  135. }
  136. })
  137. // this.list = this.list.concat(result.records);
  138. this.list = !this.keyword ? this.list.concat(result.records) : result.records
  139. }else{
  140. this.$Toast(message);
  141. }
  142. }).catch( err => {
  143. uni.hideLoading();
  144. this.$Toast(err.message);
  145. })
  146. },
  147. }
  148. }
  149. </script>
  150. <style lang="scss" scoped>
  151. .search {
  152. // position: fixed;
  153. width: 100%;
  154. top: 0;
  155. left: 0;
  156. padding: 28rpx;
  157. background: #fff;
  158. z-index: 1;
  159. }
  160. .top_bg_text{
  161. width: 100%;
  162. height: 184rpx;
  163. margin-top: 30rpx;
  164. background-size: 100% 184rpx;
  165. display: flex;
  166. flex-direction: column;
  167. align-items: center;
  168. .title_max{
  169. margin-top: 20rpx;
  170. font-size: 54rpx;
  171. font-weight: bold;
  172. color: #73B8DE;
  173. }
  174. .title_min{
  175. margin-top: 10rpx;
  176. font-size: 28rpx;
  177. color: #73B8DE;
  178. }
  179. }
  180. .pages{
  181. background-color: #F5F5F5;
  182. // padding-top: 120rpx;
  183. .top_img{
  184. margin-top: 30rpx;
  185. margin-bottom: 50rpx;
  186. height: 184rpx;
  187. }
  188. }
  189. .over_y {
  190. overflow-y: auto;
  191. }
  192. .item_goods {
  193. margin: 0 auto;
  194. width: 713rpx;
  195. margin-top: 38rpx;
  196. margin-bottom: 30rpx;
  197. background-color: #FFF;
  198. border-radius: 34rpx;
  199. box-shadow: 0 3px 6px 0 rgba(0, 0, 0, 0.16);
  200. }
  201. </style>
  202. <!--
  203. <template>
  204. <view class="pages">
  205. <view class="search"><u-search v-model="keyword" placeholder="请输入要搜索的商品" height="70" :show-action="false" @search="search" /></view>
  206. <view class="top_bg_text" :style="'background-image: url('+pageImage+')'">
  207. <text class="title_max">{{title}}</text>
  208. <text class="title_min">{{title_alt}}</text>
  209. </view>
  210. <view class="over_y">
  211. <view class="item_goods" v-for="(item,index) in list" :key="index">
  212. <goods-item :goods="item" thereTo='ZeroMoneyBuy'></goods-item>
  213. </view>
  214. </view>
  215. </view>
  216. </template>
  217. <script>
  218. import config from "@/utils/js/config.js"
  219. export default {
  220. data() {
  221. return {
  222. http_img: config.img_url,
  223. pageImage:'',
  224. title: "",
  225. title_alt: "",
  226. list: [],
  227. pageNo: 1,
  228. pageSize: 10,
  229. total: null,
  230. isLock: true,
  231. id: '',
  232. keyword: ''
  233. }
  234. },
  235. onPullDownRefresh() {
  236. this.pageNo= 1;
  237. this.total = null;
  238. this.list = [];
  239. this.getGoodsList();
  240. },
  241. onReachBottom() {
  242. if(this.isLock) {
  243. if(this.total !== null && this.pageNo * this.pageSize >= this.total){
  244. this.isLock = false;
  245. this.$Toast('没有更多数据了哦!');
  246. setTimeout(()=>{
  247. this.isLock = true;
  248. },3000)
  249. return
  250. }
  251. this.pageNo+=1;
  252. this.getGoodsList();
  253. }
  254. },
  255. onLoad(options) {
  256. this.id = options.id;
  257. this.pageImage = options.pageImage
  258. this.getGoodsList();
  259. },
  260. methods: {
  261. search () {
  262. this.pageNo = 1
  263. this.pageSize = 9999
  264. this.getGoodsList()
  265. },
  266. getGoodsList() {
  267. uni.showLoading();
  268. const params = {
  269. pageNo: this.pageNo,
  270. pageSize: this.pageSize,
  271. bottonId:this.id,
  272. title: this.keyword
  273. }
  274. this.$api('getGoodsList',params).then(res => {
  275. let { code, result, message} = res;
  276. uni.hideLoading();
  277. if(code == 200){
  278. if(this.total == null) {
  279. this.total = result.total;
  280. }
  281. result.records.forEach(item => {
  282. const picArray= item.pic.split(',')
  283. item.pic= picArray[0]
  284. })
  285. // this.list = this.list.concat(result.records);
  286. this.list = !this.keyword ? this.list.concat(result.records) : result.records
  287. }else{
  288. this.$Toast(message);
  289. }
  290. }).catch( err => {
  291. uni.hideLoading();
  292. this.$Toast(err.message);
  293. })
  294. },
  295. }
  296. }
  297. </script>
  298. <style lang="scss" scoped>
  299. .search {
  300. position: fixed;
  301. width: 100%;
  302. top: 0;
  303. left: 0;
  304. padding: 28rpx;
  305. background: #fff;
  306. z-index: 1;
  307. }
  308. .top_bg_text{
  309. width: 100%;
  310. height: 184rpx;
  311. margin-top: 30rpx;
  312. background-size: 100% 184rpx;
  313. display: flex;
  314. flex-direction: column;
  315. align-items: center;
  316. .title_max{
  317. margin-top: 20rpx;
  318. font-size: 54rpx;
  319. font-weight: bold;
  320. color: #73B8DE;
  321. }
  322. .title_min{
  323. margin-top: 10rpx;
  324. font-size: 28rpx;
  325. color: #73B8DE;
  326. }
  327. }
  328. .pages{
  329. background-color: #F5F5F5;
  330. padding-top: 120rpx;
  331. .top_img{
  332. margin-top: 30rpx;
  333. margin-bottom: 50rpx;
  334. height: 184rpx;
  335. }
  336. }
  337. .over_y {
  338. overflow-y: auto;
  339. }
  340. .item_goods {
  341. margin: 0 auto;
  342. width: 713rpx;
  343. margin-top: 38rpx;
  344. margin-bottom: 30rpx;
  345. background-color: #FFF;
  346. border-radius: 34rpx;
  347. box-shadow: 0 3px 6px 0 rgba(0, 0, 0, 0.16);
  348. }
  349. </style>
  350. -->