cm-goods-popup.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. <template name="coupon">
  2. <view class="coupon-template">
  3. <!-- 选择商品 -->
  4. <tui-bottom-popup :radius="true" :show="show" @close="hidePopup">
  5. <view class="tui-popup-box clearfix">
  6. <view class="title">选择商品</view>
  7. <view class="title-search">
  8. <view class="search-from name">
  9. <text class="iconfont icon-iconfonticonfontsousuo1"></text>
  10. <input
  11. class="input"
  12. type="text"
  13. confirm-type="search"
  14. v-model="listQuery.keyWord"
  15. @input="onShowClose"
  16. @confirm="userReportProductList()"
  17. placeholder="搜索商品名称"
  18. maxlength="16"
  19. />
  20. <text class="iconfont icon-shanchu1" v-if="isShowClose" @click="delInputText()"></text>
  21. </view>
  22. </view>
  23. <view class="tui-popup-main coupon">
  24. <scroll-view class="tui-popup-scroll" scroll-y="true">
  25. <view
  26. v-for="(pros, index) in dataList"
  27. :key="index"
  28. class="list"
  29. @click.stop="checkedCoupon(index)"
  30. >
  31. <view class="list-cell-le">
  32. <image
  33. class="logo"
  34. :src="pros.image"
  35. mode=""
  36. ></image>
  37. </view>
  38. <view class="list-cell-ri">
  39. <view class="list-text">{{ pros.name }}</view>
  40. <view class="list-text small"> <text class="none">供应商:</text>{{ pros.shopName }}</view>
  41. <view class="list-text red">¥{{ pros.price }}</view>
  42. </view>
  43. <view class="list-cell-btn">
  44. <view
  45. class="checkbox iconfont"
  46. :class="[pros.ischecked ? 'icon-yixuanze' : 'icon-weixuanze']"
  47. >
  48. </view>
  49. </view>
  50. </view>
  51. </scroll-view>
  52. </view>
  53. <view class="tui-right-flex tui-popup-btn" :style="{ paddingBottom: isIphoneX ? '68rpx' : '34rpx' }">
  54. <view class="tui-flex-1"> <view class="tui-button" @click="confirmPopup">确定</view> </view>
  55. </view>
  56. </view>
  57. </tui-bottom-popup>
  58. </view>
  59. </template>
  60. <script>
  61. export default {
  62. name: 'cmgoodspopup',
  63. props: {
  64. show: {
  65. type: Boolean,
  66. default: false
  67. }
  68. },
  69. data() {
  70. return {
  71. isIphoneX: this.$store.state.isIphoneX,
  72. checkedIndex: 0,
  73. isShowClose: false,
  74. listQuery: {
  75. keyWord:'',
  76. pageNum: 1,
  77. pageSize: 100,
  78. },
  79. dataList: []
  80. }
  81. },
  82. created() {
  83. this.userReportProductList()
  84. },
  85. methods: {
  86. async userReportProductList() {
  87. this.UserService.userReportProductList(this.listQuery)
  88. .then(response => {
  89. let data = response.data
  90. if (data.results && data.results.length > 0) {
  91. this.dataList = data.results.map((el,index)=>{
  92. el.ischecked = false
  93. return el
  94. })
  95. }
  96. })
  97. .catch(error => {
  98. this.$util.msg(error.msg, 2000)
  99. })
  100. },
  101. checkedCoupon(idx) {
  102. // 选择商品
  103. this.checkedIndex = idx
  104. this.dataList.forEach((el, index) => {
  105. if (this.checkedIndex == index) {
  106. el.ischecked = !el.ischecked
  107. } else {
  108. el.ischecked = false
  109. }
  110. })
  111. },
  112. onShowClose() {
  113. //输入框失去焦点时触发
  114. if (this.listQuery.name != '') {
  115. this.isShowClose = true
  116. } else {
  117. this.isShowClose = false
  118. }
  119. },
  120. delInputText() {
  121. //清除输入框内容
  122. this.listQuery.name = ''
  123. this.isShowClose = false
  124. },
  125. hidePopup(){
  126. this.$parent.isGoodspopup = false
  127. },
  128. confirmPopup() {
  129. let goods = null
  130. let checkedData = false
  131. this.dataList.forEach((el, index) => {
  132. if (el.ischecked) {
  133. goods = el
  134. checkedData = true
  135. }
  136. })
  137. if(!checkedData){
  138. this.$util.msg('请选择商品~', 2000)
  139. return
  140. }
  141. this.$emit('handleChoiceaGoods', goods)
  142. this.$parent.isGoodspopup = false
  143. }
  144. }
  145. }
  146. </script>
  147. <style lang="scss">
  148. .coupon-template {
  149. width: 100%;
  150. height: auto;
  151. background: #ffffff;
  152. float: left;
  153. margin-top: 24rpx;
  154. .coupon-title {
  155. width: 702rpx;
  156. padding: 0 24rpx;
  157. height: 88rpx;
  158. line-height: 88rpx;
  159. position: relative;
  160. .text {
  161. font-size: $font-size-28;
  162. color: $text-color;
  163. }
  164. .text-coupon {
  165. display: inline-block;
  166. float: right;
  167. padding-right: 30rpx;
  168. line-height: 88rpx;
  169. font-size: 28rpx;
  170. color: #f94b4b;
  171. }
  172. .iconfont {
  173. width: 50rpx;
  174. height: 88rpx;
  175. line-height: 88rpx;
  176. color: #999999;
  177. display: block;
  178. position: absolute;
  179. right: 0;
  180. top: 0;
  181. }
  182. }
  183. }
  184. .tui-popup-box {
  185. position: relative;
  186. box-sizing: border-box;
  187. min-height: 220rpx;
  188. padding: 24rpx 32rpx 0 32rpx;
  189. .title {
  190. font-size: $font-size-32;
  191. color: $text-color;
  192. line-height: 68rpx;
  193. text-align: center;
  194. float: left;
  195. width: 100%;
  196. height: 68rpx;
  197. box-sizing: border-box;
  198. padding: 0 24rpx;
  199. }
  200. .title-search {
  201. width: 100%;
  202. height: 66rpx;
  203. background: #ffffff;
  204. box-sizing: border-box;
  205. float: left;
  206. .search-from {
  207. width: 100%;
  208. height: 100%;
  209. background: #f7f7f7;
  210. border-radius: 32rpx;
  211. float: left;
  212. position: relative;
  213. .input {
  214. width: 500rpx;
  215. height: 64rpx;
  216. float: left;
  217. line-height: 64rpx;
  218. color: $text-color;
  219. font-size: $font-size-24;
  220. }
  221. .icon-iconfonticonfontsousuo1 {
  222. width: 64rpx;
  223. height: 64rpx;
  224. line-height: 64rpx;
  225. text-align: center;
  226. display: block;
  227. font-size: $font-size-38;
  228. float: left;
  229. color: #999999;
  230. }
  231. .icon-shanchu1 {
  232. font-size: $font-size-32;
  233. color: #999999;
  234. position: absolute;
  235. width: 64rpx;
  236. height: 64rpx;
  237. line-height: 64rpx;
  238. text-align: center;
  239. top: 0;
  240. right: 0;
  241. z-index: 10;
  242. }
  243. }
  244. }
  245. .tui-popup-main {
  246. width: 100%;
  247. float: left;
  248. padding-top: 10rpx;
  249. .tui-popup-scroll {
  250. width: 100%;
  251. height: 800rpx;
  252. .list {
  253. width: 100%;
  254. height: 176rpx;
  255. box-sizing: border-box;
  256. padding: 24rpx 0;
  257. background-size: cover;
  258. .list-cell-le {
  259. width: 128rpx;
  260. height: 100%;
  261. box-sizing: border-box;
  262. float: left;
  263. border: 1px dashed #e1e1e1;
  264. .logo {
  265. width: 125rpx;
  266. height: 125rpx;
  267. border-radius: 8rpx;
  268. }
  269. }
  270. .list-cell-ri {
  271. width: 470rpx;
  272. height: 100%;
  273. box-sizing: border-box;
  274. float: left;
  275. margin-left: 24rpx;
  276. .list-text{
  277. width: 100%;
  278. height: 42rpx;
  279. float: left;
  280. line-height: 42rpx;
  281. text-align: left;
  282. font-size: $font-size-26;
  283. color: #333333;
  284. text-overflow: ellipsis;
  285. overflow: hidden;
  286. display: -webkit-box;
  287. -webkit-line-clamp: 1;
  288. line-clamp: 1;
  289. -webkit-box-orient: vertical;
  290. &.small{
  291. font-size: 24rpx;
  292. .none{
  293. color: #999;
  294. }
  295. }
  296. &.red{
  297. color: #F94B4B;
  298. }
  299. }
  300. }
  301. .list-cell-btn {
  302. width: 40rpx;
  303. height: 100%;
  304. float: right;
  305. .checkbox {
  306. width: 40rpx;
  307. line-height: 128rpx;
  308. float: right;
  309. box-sizing: border-box;
  310. text-align: center;
  311. text-decoration: none;
  312. -webkit-tap-highlight-color: transparent;
  313. overflow: hidden;
  314. font-size: $font-size-34;
  315. &.icon-weixuanze {
  316. color: #b2b2b2;
  317. }
  318. &.icon-yixuanze {
  319. color: #FF5B00;
  320. }
  321. }
  322. }
  323. }
  324. }
  325. .tui-popup-coupon {
  326. width: 100%;
  327. height: 500rpx;
  328. box-sizing: border-box;
  329. padding: 30rpx 20rpx;
  330. .tui-popup-h1 {
  331. width: 100%;
  332. height: 66rpx;
  333. display: flex;
  334. align-items: center;
  335. .tui-popup-text {
  336. flex: 1;
  337. height: 66rpx;
  338. line-height: 66rpx;
  339. font-size: $font-size-30;
  340. color: #333333;
  341. &.red {
  342. color: #f94b4b;
  343. }
  344. &.bold {
  345. font-weight: bold;
  346. }
  347. &.left {
  348. text-align: left;
  349. }
  350. &.right {
  351. text-align: right;
  352. }
  353. }
  354. }
  355. }
  356. }
  357. .tui-popup-btn {
  358. width: 100%;
  359. height: auto;
  360. float: left;
  361. margin-top: 24rpx;
  362. .tui-button {
  363. width: 100%;
  364. height: 88rpx;
  365. background: $btn-confirm;
  366. line-height: 88rpx;
  367. text-align: center;
  368. color: #ffffff;
  369. font-size: $font-size-28;
  370. border-radius: 44rpx;
  371. }
  372. }
  373. }
  374. </style>