app-model.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <view class="app-mode" :class="{'app-show': display}">
  3. <view class="app-content">
  4. <view class="app-top">
  5. <view class="app-content-image">
  6. <image class="app-image" :src="coverPic"></image>
  7. </view>
  8. <view class="app-number dir-top-nowrap">
  9. <text class="app-price">¥{{price}}</text>
  10. <text>库存: {{goodsNum}}</text>
  11. </view>
  12. <view class="app-close" @click.stop="close"></view>
  13. </view>
  14. <view class="app-center">
  15. <view class="app-attr dir-top-nowrap main-center" v-for="(item, index) in attrGroup" :key="index">
  16. <text>{{item.attr_group_name}}</text>
  17. <view class="dir-left-nowrap main-left">
  18. <view class="app-item" v-for="(attr, num) in item.attr_list" :key="num" :class="{'app-attr-index': attrIndex === index}">{{attr.attr_name}}</view>
  19. </view>
  20. </view>
  21. <view class="app-add-subtract dir-left-nowrap main-between cross-center">
  22. <text>数量</text>
  23. <view class="app-input dir-left-nowrap main-between cross-center">
  24. <view class="app-icon" @click="subtract">-</view>
  25. <input type="number" v-model="number">
  26. <view class="app-icon" @click="add">+</view>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="app-bottom dir-left-nowrap">
  31. <view>
  32. <app-form-id>
  33. <button class="app-add">加入购物车</button>
  34. </app-form-id>
  35. </view>
  36. <view>
  37. <app-form-id @click="jumpGo">
  38. <button class="app-buy">立即购买</button>
  39. </app-form-id>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. export default {
  47. name: 'app-model',
  48. props: {
  49. value: {
  50. type: Boolean,
  51. default: function() {
  52. return true;
  53. }
  54. },
  55. attrGroup: {
  56. type: Array,
  57. default: function() {
  58. return [];
  59. }
  60. },
  61. coverPic: {
  62. type: String,
  63. default: function() {
  64. return 'http://matianxia.oss-cn-qingdao.aliyuncs.com/uploads/20190511/0f724bf010aebf9a999ac39beb44eadf.jpg?x-oss-process=style/q90';
  65. }
  66. },
  67. price: {
  68. type: String,
  69. default: function() {
  70. return '100.5';
  71. }
  72. },
  73. goodsNum: {
  74. type: Number,
  75. default: function() {
  76. return 0;
  77. }
  78. }
  79. },
  80. data() {
  81. return {
  82. display: this.value,
  83. number: 1
  84. }
  85. },
  86. methods: {
  87. close() {
  88. this.display = false;
  89. this.$emit('input', this.display);
  90. },
  91. jumpGo() {
  92. this.$jump({
  93. open_type: 'navigate',
  94. url: '/pages/index/index'
  95. })
  96. },
  97. subtract() {
  98. if (this.number !== 0) {
  99. this.number--;
  100. }
  101. },
  102. add() {
  103. this.number++;
  104. }
  105. },
  106. watch: {
  107. value: function() {
  108. this.display = this.value;
  109. }
  110. }
  111. }
  112. </script>
  113. <style scoped lang="scss">
  114. .app-mode {
  115. position: fixed;
  116. z-index: 1600;
  117. top: 0;
  118. left: 0;
  119. width: #{750rpx};
  120. height: 100%;
  121. background-color:rgba(127, 127, 127, 0.4);
  122. transition: all 0.2s linear;
  123. visibility: hidden;
  124. opacity: 0;
  125. overflow: hidden;
  126. .app-content {
  127. position: absolute;
  128. bottom: 0;
  129. background-color: white;
  130. .app-top {
  131. width: $screen-width;
  132. height: #{142rpx};
  133. padding: 0 #{24rpx};
  134. background-color: white;
  135. border-bottom: #{1rpx} solid #e2e2e2;
  136. position: relative;
  137. .app-content-image {
  138. width: #{200rpx};
  139. height: #{205rpx};
  140. background-color: white;
  141. position: absolute;
  142. top: #{-63rpx};
  143. border-top-left-radius: #{20rpx};
  144. border-top-right-radius: #{20rpx};
  145. .app-image {
  146. width: #{192rpx};
  147. height: #{188rpx};
  148. margin-top: #{8rpx};
  149. margin-left: #{4rpx};
  150. margin-right: #{4rpx};
  151. border-bottom-left-radius: #{20rpx};
  152. border-bottom-right-radius: #{20rpx};
  153. }
  154. }
  155. .app-number {
  156. width: #{446rpx};
  157. height: 100%;
  158. position: absolute;
  159. left: #{224rpx};
  160. padding-top: #{49rpx};
  161. padding-left: #{24rpx};
  162. text {
  163. font-size: #{24rpx};
  164. color: #666666;
  165. }
  166. .app-price {
  167. color: #ff4544;
  168. margin-bottom: #{18rpx};
  169. }
  170. }
  171. .app-close {
  172. width: #{23rpx};
  173. height: #{23rpx};
  174. background-image: url("./image/close.png");
  175. background-size: cover;
  176. background-repeat: no-repeat;
  177. position: absolute;
  178. right: #{26rpx};
  179. top: #{20rpx};
  180. }
  181. }
  182. .app-bottom {
  183. width: 100%;
  184. height: #{110rpx};
  185. >view {
  186. width: 50%;
  187. height: 100%;
  188. button {
  189. width: 100%;
  190. height: 100%;
  191. line-height: #{110rpx};
  192. border: none;
  193. font-size: #{28rpx};
  194. color:white;
  195. border-radius: 0;
  196. }
  197. button:after {
  198. display: none;
  199. }
  200. .app-add {
  201. background-color: #f39800;
  202. }
  203. .app-add:active {
  204. background-color: #f39800;
  205. }
  206. .app-buy {
  207. background-color: #ff4544;
  208. }
  209. .app-buy:active {
  210. background-color: #ff4544;
  211. }
  212. }
  213. }
  214. .app-center {
  215. width: 100%;
  216. padding: 0 #{24rpx};
  217. .app-add-subtract {
  218. border-top: #{1rpx} solid #e2e2e2;
  219. height: #{124rpx};
  220. width: 100%;
  221. text {
  222. height: #{23rpx};
  223. color: #666666;
  224. }
  225. .app-input {
  226. width: #{182rpx};
  227. height: #{26rpx};
  228. input {
  229. font-size: #{20rpx};
  230. text-align: center;
  231. width: #{130rpx};
  232. }
  233. .app-icon {
  234. width: #{26rpx};
  235. height: #{26rpx};
  236. font-size: #{35rpx};
  237. text-align: center;
  238. line-height: #{26rpx};
  239. font-weight: bold;
  240. color: #999999;
  241. }
  242. }
  243. }
  244. .app-attr {
  245. width: 100%;
  246. height: #{160rpx};
  247. .app-item {
  248. color: #5e5e5e;
  249. background-color: white;
  250. height: #{57rpx};
  251. padding: 0 #{24rpx};
  252. line-height: #{57rpx};
  253. border-radius: #{10rpx};
  254. }
  255. .app-attr-index {
  256. background-color: #ff4544;
  257. color: white;
  258. }
  259. text {
  260. font-size: #{23rpx};
  261. color: #666666;
  262. }
  263. }
  264. }
  265. }
  266. }
  267. .app-show {
  268. opacity: 1;
  269. visibility: visible;
  270. }
  271. </style>