app-model.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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. console.log(1);
  93. this.$jump({
  94. open_type: 'navigate',
  95. url: '/pages/index/index'
  96. })
  97. },
  98. subtract() {
  99. if (this.number !== 0) {
  100. this.number--;
  101. }
  102. },
  103. add() {
  104. this.number++;
  105. }
  106. },
  107. computed: {
  108. },
  109. watch: {
  110. value: function() {
  111. this.display = this.value;
  112. }
  113. }
  114. }
  115. </script>
  116. <style scoped lang="scss">
  117. .app-mode {
  118. position: fixed;
  119. z-index: 1600;
  120. top: 0;
  121. left: 0;
  122. width: #{750rpx};
  123. height: 100%;
  124. background-color:rgba(127, 127, 127, 0.4);
  125. transition: all 0.2s linear;
  126. visibility: hidden;
  127. opacity: 0;
  128. overflow: hidden;
  129. .app-content {
  130. position: absolute;
  131. bottom: 0;
  132. background-color: white;
  133. .app-top {
  134. width: $screen-width;
  135. height: #{142rpx};
  136. padding: 0 #{24rpx};
  137. background-color: white;
  138. border-bottom: #{1rpx} solid #e2e2e2;
  139. position: relative;
  140. .app-content-image {
  141. width: #{200rpx};
  142. height: #{205rpx};
  143. background-color: white;
  144. position: absolute;
  145. top: #{-63rpx};
  146. border-top-left-radius: #{20rpx};
  147. border-top-right-radius: #{20rpx};
  148. .app-image {
  149. width: #{192rpx};
  150. height: #{188rpx};
  151. margin-top: #{8rpx};
  152. margin-left: #{4rpx};
  153. margin-right: #{4rpx};
  154. border-bottom-left-radius: #{20rpx};
  155. border-bottom-right-radius: #{20rpx};
  156. }
  157. }
  158. .app-number {
  159. width: #{446rpx};
  160. height: 100%;
  161. position: absolute;
  162. left: #{224rpx};
  163. padding-top: #{49rpx};
  164. padding-left: #{24rpx};
  165. text {
  166. font-size: #{24rpx};
  167. color: #666666;
  168. }
  169. .app-price {
  170. color: #ff4544;
  171. margin-bottom: #{18rpx};
  172. }
  173. }
  174. .app-close {
  175. width: #{23rpx};
  176. height: #{23rpx};
  177. background-image: url("./image/close.png");
  178. background-size: cover;
  179. background-repeat: no-repeat;
  180. position: absolute;
  181. right: #{26rpx};
  182. top: #{20rpx};
  183. }
  184. }
  185. .app-bottom {
  186. width: 100%;
  187. height: #{110rpx};
  188. >view {
  189. width: 50%;
  190. height: 100%;
  191. button {
  192. width: 100%;
  193. height: 100%;
  194. line-height: #{110rpx};
  195. border: none;
  196. font-size: #{28rpx};
  197. color:white;
  198. border-radius: 0;
  199. }
  200. button:after {
  201. display: none;
  202. }
  203. .app-add {
  204. background-color: #f39800;
  205. }
  206. .app-add:active {
  207. background-color: #f39800;
  208. }
  209. .app-buy {
  210. background-color: #ff4544;
  211. }
  212. .app-buy:active {
  213. background-color: #ff4544;
  214. }
  215. }
  216. }
  217. .app-center {
  218. width: 100%;
  219. padding: 0 #{24rpx};
  220. .app-add-subtract {
  221. border-top: #{1rpx} solid #e2e2e2;
  222. height: #{124rpx};
  223. width: 100%;
  224. text {
  225. height: #{23rpx};
  226. color: #666666;
  227. }
  228. .app-input {
  229. width: #{182rpx};
  230. height: #{26rpx};
  231. input {
  232. font-size: #{20rpx};
  233. text-align: center;
  234. width: #{130rpx};
  235. }
  236. .app-icon {
  237. width: #{26rpx};
  238. height: #{26rpx};
  239. font-size: #{35rpx};
  240. text-align: center;
  241. line-height: #{26rpx};
  242. font-weight: bold;
  243. color: #999999;
  244. }
  245. }
  246. }
  247. .app-attr {
  248. width: 100%;
  249. height: #{160rpx};
  250. .app-item {
  251. color: #5e5e5e;
  252. background-color: white;
  253. height: #{57rpx};
  254. padding: 0 #{24rpx};
  255. line-height: #{57rpx};
  256. border-radius: #{10rpx};
  257. }
  258. .app-attr-index {
  259. background-color: #ff4544;
  260. color: white;
  261. }
  262. text {
  263. font-size: #{23rpx};
  264. color: #666666;
  265. }
  266. }
  267. }
  268. }
  269. }
  270. .app-show {
  271. opacity: 1;
  272. visibility: visible;
  273. }
  274. </style>